小程序
小游戏
企业微信
微信支付
扫描小程序码分享
这几天又遇到一个问题,就是不知道微信小程序js文件中的函数之间能否继承呢,哪有具体的例子。就是我想在一个function中使用另一个function中的变量。不知道是否可以?求好心人赐教 ^_^不胜感激。
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
我这个用的少。。不知道你是不是这个意思
function f1(){
this.name = "luxiaoxiao"
}
function f2(){
let instance = new f1()
console.log(instance.name)
f2()
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
还不知道你是小哥哥还是小姐姐,不过真的谢谢啊,几次给我帮忙。
举个例子,我现在就是想在函数son中调用函数chooselocation中的变量。刚才试了你说的方法,他报错说son函数中的chooselocation未定义。我也尝试了https://www.hishop.com.cn/xiaocx/show_36812.html 中的方法,也不行 o(╥﹏╥)o
chooselocation: function (e) {
var that = this
wx.chooseLocation({
success: function (res) {
that.setData({
location: {
latitude: res.latitude,
longitude: res.longitude,
name: res.name
})
},
fail: function (res) {
complete: function (res) {
son: function (e) {
var ww = new chooselocation()
console.log(ww.name)
你这样的啊。。你son里直接 this.data.location.name就可以了啊
果然是 o(╥﹏╥)o 谢谢啦
对不起 我是男的
没区别 哈哈
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
我这个用的少。。不知道你是不是这个意思
function f1(){
this.name = "luxiaoxiao"
}
function f2(){
let instance = new f1()
console.log(instance.name)
}
f2()
还不知道你是小哥哥还是小姐姐,不过真的谢谢啊,几次给我帮忙。
举个例子,我现在就是想在函数son中调用函数chooselocation中的变量。刚才试了你说的方法,他报错说son函数中的chooselocation未定义。我也尝试了https://www.hishop.com.cn/xiaocx/show_36812.html 中的方法,也不行 o(╥﹏╥)o
chooselocation: function (e) {
var that = this
wx.chooseLocation({
success: function (res) {
that.setData({
location: {
latitude: res.latitude,
longitude: res.longitude,
name: res.name
}
})
},
fail: function (res) {
},
complete: function (res) {
}
})
},
son: function (e) {
var ww = new chooselocation()
console.log(ww.name)
},
你这样的啊。。你son里直接 this.data.location.name就可以了啊
果然是 o(╥﹏╥)o 谢谢啦
对不起 我是男的
没区别 哈哈