小程序中页面分享时报错,[app.json 或自定义编译条件错误] app.json 中未定义自定义编译中指定的启动页面 ./pages/index/index(env: Windows),
有时在做小程序分享功能时会报错,分享后页面呈现空白状态
[app.json 或自定义编译条件错误] app.json 中未定义自定义编译中指定的启动页面 ./pages/index/index(env: Windows,),
或者是这种提示
Page "./pages/index/index" has not been registered yet.
报错原因:
已经有明显的提示了,就是未找到这个页面,这里主要是 path 路径错误,看看自己填写的路径是否与app.json中的路径是否相同
onShareAppMessage: function(res) {
return {
title: '小程序分享', // 分享名称
path: 'pages/index/index', // 这里写你这个页面的路径
imageUrl:'', //这个是显示的图片,非必填
success: function (shareTickets) {
console.log(shareTickets + '成功');
// 转发成功
},
fail: function (res) {
console.log(res + '失败');
// 转发失败
},
complete:function(res){
// 不管成功失败都会执行
}
}
}