uniapp renderjs

官网

调用 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" 分开,别写一个标签就好了

原文

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值