H5端正常,App端真机调试时无法正常使用
renderjs部分
<script module="testModule" lang="renderjs">
export default {
mounted() {
},
methods: {
sayHello(){
console.log("Say Hello!");
}
}
};
</script>
vue组件
<uni-button @click="consoleLog('666666');testModule.sayHello()">888</uni-button>
<script>
export default {
name: "FunctionPlotter",
data() {
return {
valu: '',
valus: [],
}
},
methods: {
consoleLog(v) {
console.log(v);
},
closeDialog() {
this.valu = '';
this.$emit('closeDialog', true);
}
}
}
</script>
报错输出:
[Vue warn]: Property or method "testModule" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
found in
---> <FunctionPlotter> at components/FunctionPlotter.vue:1
<UniTransition> at uni_modules/uni-transition/components/uni-transition/uni-transition.vue:1
<UniPopup> at uni_modules/uni-popup/components/uni-popup/uni-popup.vue:1
at pages/index/index.vue:1
17:16:24.054 [Vue warn]: Error in v-on handler: "TypeError: Cannot read property 'sayHello' of undefined"
found in
---> <FunctionPlotter> at components/FunctionPlotter.vue:1
<UniTransition> at uni_modules/uni-transition/components/uni-transition/uni-transition.vue:1
<UniPopup> at uni_modules/uni-popup/components/uni-popup/uni-popup.vue:1
at pages/index/index.vue:1
17:16:24.060 TypeError: Cannot read property 'sayHello' of undefined
2 个回复
爱吃鱼的靖哥哥 - 行走在全栈路上的码农
大佬解决了吗
aak12345
https://uniapp.dcloud.net.cn/api/window/communication.html uni主动发消息给iframe,可以在renderjs里面添加uni.$on,然后在uni里面uni.$emit