uni-app
uni-app copied to clipboard
vue3版本开启virtualHost编译到抖音小程序watch监听不生效
<template>
<view>
<button @click="test">
test
</button>
<button @click="test1">test1</button>
</view>
</template>
<script setup>
import { watch } from 'vue';
const emits = defineEmits(['click', 'upload']);
const props = defineProps({
name: {
type: String,
default: 'hello'
}
})
function test() {
emits('click');
}
function test1() {
emits('upload');
}
watch(() => props.name,
(val) => {
console.log(val)
}, {
immediate: true
})
</script>
<template>
<view class="content">
<button1 :name="name" @click="test" @upload="upload"></button1>
<button @click="name = 'aaaaaaaaaa'">点击修改name</button>
</view>
</template>
<script setup>
import { ref } from 'vue';
const name = ref('test')
function test() {
console.log("click")
}
function upload() {
console.log('upload')
}
</script>
预期结果:打印aaaaaaaaaa 实际结果:无