调用 renderjs
里的事件可以像下面这样写
:changnumber="改变的值" :change:changnumber="canvasImage.事件名"
changnumber
自定义名,change.自定义名
=“renderjs.事件名”
直接调用的
@click="canvasImage.send"
<template>
<view>
<button @click="num++" :changnumber="num" :change:changnumber="canvasImage.channumber">num {{num}}
点击</button>
<button @click="checked = !checked" :changboolean="checked"
:change:changboolean="canvasImage.chanchecked">checked {{checked}} 点击</button>
<button @click="canvasImage.send">我直接触发</button>
<br />
<view>我是 renderjs 我正在改变{{total}}</view>
</view>
</template>
<script>
export default {
data() {
return {
total: 0,
checked: false,
num: 0
}
},
onLoad() {},
methods: {
reciveMessage: function(data) {
this.total = data;
}
}
}
</script>
<script module="canvasImage" lang="renderjs">
export default {
data() {
return {
count: 0
}
},
methods: {
channumber(newValue, oldValue, ownerVm, vm) {
console.log('newValue', newValue)
this.count = newValue
this.send()
},
chanchecked(newValue, oldValue, ownerVm, vm) {
console.log('newValue', newValue)
console.log('oldValue', oldValue)
console.log('ownerVm', ownerVm)
console.log('vm', vm)
},
send(e, ownerFun) {
// 向页面传参
if (ownerFun) {
console.log('我直接被触发了',e)
console.log('我直接被触发了',ownerFun)
ownerFun.callMethod('reciveMessage', this.count)
} else {
console.log('我是调用的')
this.$ownerInstance.callMethod('reciveMessage', this.count)
}
},
}
}
</script>
<style>
</style>
还有一点就是,如果你遇到在 h5 端能触发 renderjs
的事件,但是发现在app端不能触发的话,就把 @click
和 :changboolean="checked" :change:changboolean="canvasImage.chanchecked"
分开,别写一个标签就好了