<template>
<view id="map-container"
:prop="isLocation"
:change:prop="mapModule.geolocation"
>
</view>
</template>
<script>
import { onMounted, ref, reactive, defineComponent, toRefs, watch } from 'vue';
export default defineComponent({
setup() {
const state = reactive({
isLocation: false
})
onMounted(() => {
setTimeout(() => (state.isLocation = true), 2000)
})
function showToast(data) {
uni.showToast({
title: data,
icon: 'none'
})
}
return {
...toRefs(state),
showToast
}
}
})
</script>
<script module="mapModule" lang="renderjs">
export default {
data () {
return {
map: null
}
},
methods: {
geolocation(newLocation, oldLocation) {
const that = this;
that.$ownerInstance && that.$ownerInstance.callMethod("showToast", '进入了')
}
}
}
</script>
这样运行直接白屏
<template>
<view>
<view @click="mapModule.geolocation">
点击通讯
</view>
<view id="map-container" :prop="isLocation" > </view>
</view>
</template>
<script>
import { onMounted, ref, reactive, defineComponent, toRefs, watch } from 'vue';
export default defineComponent({
setup() {
const state = reactive({
isLocation: false
})
onMounted(() => {
setTimeout(() => (state.isLocation = true), 2000)
})
function showToast(data) {
uni.showToast({
title: data,
icon: 'none'
})
}
return {
...toRefs(state),
showToast
}
}
})
</script>
<script module="mapModule" lang="renderjs">
export default {
data () {
return {
map: null
}
},
methods: {
geolocation(newLocation, oldLocation) {
const that = this;
that.$ownerInstance && that.$ownerInstance.callMethod("showToast", '进入了')
}
}
}
</script>
这样就可以
0 个回复