小程序内嵌一个webview,使用的vue3项目。
jssdk的npm版本:1.6.5
使用wx.config配置过
const url = window.location.href;
apiGetWXSignature(url).then((res) => {
wx.config({
debug: false,
appId: res.content.appid,
timestamp: res.content.timestamp,
nonceStr: res.content.nonceStr,
signature: res.content.signature,
jsApiList: ["openLocation"],
});
});
使用时:
wx.checkJsApi({
jsApiList: ["openLocation"],
success: function (res) {
if (res.checkResult.openLocation === false) {
ElMessage({
message: "微信版本过低,无法使用该功能",
type: "error",
});
return;
}
wx.openLocation({
latitude: parseFloat(project.value.location.latitude),
longitude: parseFloat(project.value.location.longitude),
name: project.value.location.name,
address: project.value.location.address,
scale: 28,
infoUrl: "",
success: (res) => {
console.log(res);
ElMessage({
message: res,
type: "info",
});
apiMiniLog({ type: "openLocationSuccess", content: res }).then((res) => {
console.log(res);
});
},
fail: (err) => {
ElMessage({
message: err,
type: "error",
});
apiMiniLog({ type: "openLocationFail", content: err }).then((res) => {
console.log(res);
});
},
});
},
fail: function () {
ElMessage({
message: "微信版本过低,无法使用该功能",
type: "error",
});
},
});
结果是:
jsCheckApi中 openLocation:true
但是接口调用提示 openLocation:permission denied
这是为什么?
你好,Debug下是不是用错appid了