[自动热重载错误 appservice 生成错误] pages/index/index.js: file: pages/index/index.js
unknown: In strict mode code, functions can only be declared at top level or inside a block. (53:21)
51 | * 用户点击右上角分享
52 | */
> 53 | onShareAppMessage: function () {
| ^
54 | return {
55 | title: '欢迎品鉴',
56 | path: '/pages/index/index',(env: Windows,mp,1.06.2306020; lib: 2.32.3)
源代码如下,楼主想实现这个页面分享功能。结果报这个错,有大神看下,问题出在哪里
//获取应用实例
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
screenHeight: app.screenHeight,//获取屏幕高度
statusBarHeight: app.statusBarHeight,//获取状态栏高度
navBarHeight: app.navBarHeight,//获取导航栏高度
changeIndex: 0,
video: [{
id: 0,
video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/柒柒,180元小时.mp4"
},{
id: 1,
video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/艾艾,160元小时.mp4"
}, {
id: 2,
video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/蓝蓝,180元小时.mp4"
}, {
id: 3,
video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/小琪,140元小时.mp4"
}, {
id: 4,
video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/唐唐,170元小时.mp4"
}, {
id: 5,
video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/蓝琪,170元小时.mp4"
}, {
id: 6,
video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/阳阳,130元小时.mp4"
}, {
id: 7,
video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/采平,100元小时.mp4"
}, {
id: 8,
video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/青竹,130元小时.mp4"
}]
},
//划动切换
slide(e) {
this.setData({
changeIndex: e.detail.current
})
console.log(e.detail.current)
}
})
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
return {
title: '欢迎品鉴',
path: '/pages/index/index',
desc:'分享描述'
}
}
})
const app = getApp() Page({ /** * 页面的初始数据 */ data: { screenHeight: app.screenHeight, //获取屏幕高度 statusBarHeight: app.statusBarHeight, //获取状态栏高度 navBarHeight: app.navBarHeight, //获取导航栏高度 changeIndex: 0, video: [{ id: 0, video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/柒柒,180元小时.mp4" }, { id: 1, video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/艾艾,160元小时.mp4" }, { id: 2, video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/蓝蓝,180元小时.mp4" }, { id: 3, video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/小琪,140元小时.mp4" }, { id: 4, video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/唐唐,170元小时.mp4" }, { id: 5, video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/蓝琪,170元小时.mp4" }, { id: 6, video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/阳阳,130元小时.mp4" }, { id: 7, video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/采平,100元小时.mp4" }, { id: 8, video: "cloud://prod-2g73fcse527d9ada.7072-prod-2g73fcse527d9ada-1319043696/青竹,130元小时.mp4" }] }, //划动切换 slide(e) { this.setData({ changeIndex: e.detail.current }) console.log(e.detail.current) }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { title: '欢迎品鉴', path: '/pages/index/index', desc: '分享描述' } } })