赞
踩
///uniapp x 中使用
<uts-hello-view buttonText="点击按钮内容" style="width:375px;height: 375px;background-color: aqua;"></uts-hello-view>
方法:build settings->User Script Sandboxing 修改为NO
首先,swift必须是public 或者open修饰,比如 public class NHT_DemoView
但是高德地图又不能用这个修饰,所以将高德地图添加到一个view上,然后将这个view添加到另一个通过
public修饰的类上,通过这个类调用高德地图的api;
swift:
@objc open var SelectLocationChangeBlock: (([String:Any])->Void)?
UTS插件:
NVLoad() : NHT_DemoView {
// -----NHT_AMAPView
let button = new NHT_DemoView()
button.SelectLocationChangeBlock = (res : any) => {
this.$emit('fetchgis', res)
};
return button
},
因为传值类型不对,可以自己声明一个变量,然后当参数传值
const map1 = new Map<string,any>()
map1.set('a', 'alpha');
或者改变响应回调的写法(必须按照你实际的返回内容),
button.SelectLocationChangeBlock = (res : Map<string, any>) => {
this.$emit('fetchgis', res)
};
可能是watch中出现的问题
比如监听下面的值
“enableLocation”: {//允许定位
type: Boolean,
default: false
},
watch: {
//这样写对,必须有newValue : boolean, oldVel : boolean,只有newValue会报这个错误
“enableLocation”: {
handler(newValue : boolean, oldVel : boolean) {
// if (!this.isInitLocation && newValue && !this.innerEnableLocation) {
// this.isInitLocation = true
// this.innerEnableLocation = newValue
// this.initLocation()
// }
},
immediate: false
},
}
只能全部小写,有大写的不行,比如下面fetchGis就不行,而fetchgis可以
emits: [‘fetchGis’, “locate”, “hhhh”, “fetchgis”],
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。