wxs 文件
function touchstartEvent(e, ins) {
console.log('touchstartEvent');
ins.callMethod('wxsCall', 'touchstartEvent')
}
function touchmoveEvent(e, ins) {
console.log('touchmoveEvent');
ins.callMethod('wxsCall', 'touchmoveEvent')
}
function touchendEvent(e, ins) {
console.log('touchendEvent');
ins.callMethod('wxsCall', 'touchendEvent')
}
module.exports = {
// propObserver: propObserver,
// callObserver: callObserver,
touchstartEvent: touchstartEvent,
touchmoveEvent: touchmoveEvent,
touchendEvent: touchendEvent
}
vue文件
<template>
<view class="container wxs-demo" @touchstart="wxsTest.touchstartEvent" @touchmove="wxsTest.touchmoveEvent"
@touchend="wxsTest.touchendEvent" @touchcancel="wxsTest.touchendEvent">
</view>
</template>
<!-- 微信小程序, QQ小程序, app, h5使用wxs -->
<!-- #ifdef MP-WEIXIN || MP-QQ || APP-PLUS || H5 -->
<script src="./test.wxs" module="wxsTest" lang="wxs"></script>
<!-- #endif -->
<script setup>
const wxsCall = (data)=>{
console.log(data,2222222);
}
</script>
<style lang="scss" scoped>
.wxs-demo{
width: 500rpx;
height: 500rpx;
background-color: red;
}
</style>
itmonkey (作者)
好的
2022-02-08 17:25