<script setup>
import { computed } from 'vue';
const { num } = defineProps(['num']);
const state = computed(() => (num % 2 === 0 ? 'even' : 'odd'));
</script>
<template>
<div>The number {{ num }} is {{ state }}</div>
</template>
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: Win11
第三方开发者工具版本号: Nightly 1.06.2501162
基础库版本号: 3.7.5
项目创建方式: CLI
CLI版本号: latest
<script setup>
import { computed } from 'vue';
const { num } = defineProps(['num']);
const state = computed(() => (num % 2 === 0 ? 'even' : 'odd'));
</script>
<template>
<div>The number {{ num }} is {{ state }}</div>
</template>
预期能够在界面当中根据num的变化产生state的变化
并未产生响应式的计算
看一下这个
https://play.vuejs.org/#eNrNlMtu2zAQRX9lQKCQjQRSKu9cyX0YWaSLNmizK7twpLHNRCIFPlwDgv69QyqykjRxF0WR7MS5h9Sd4ZVa9rFp4p1DNmeZKbRoLBi0rllwKepGaQstaFxDB2utauCMWM7eHdTlVlTl20GMk37tT+TsIZQ+gtKnoNkjaDZAXBZKGgvS1ZB7R5OzKZdZ0nsmt7SwWDfVyiKtALJrZ62S8KGoRHGbc0Y7T044W1zIQuPKYJb0RE+XYrdYKietmUPbhtd0XZb4ctDv+pyT0J/FGST3pPR5afanlCUHr+yUWUO9rcUmvjFK0kW0fi9nhaobUaH+2lhBvXNGzrzitVVVqV+fQ81qh6dDvdhicftE/cbsfY2zS40G9Y5metDsSm/Q9vL59y+4p+eDWKvSVUQfEb+hUZXzHnvsk5Ml2b7HBbcX4ZqF3FyZ871FaYamvFFPdoEPCVseaX20O4vTsI/LjqY4Ju9Ylv1QncVyCHREfERxHvJ1d/WUsRLXQuKlVo2Z/IioGv2cEthjxtLdETQcN5lMIV/AxG9+AynkeQ5n8B4i3KGMYA6RKsto6g84llkft6steg/XqMcggjB+0b91zOXDGI1f1b8MoPEN/639cUoBf/VTCb+R/z6V59oPm+OXG0L3G2ih+Jk=
我在官方的playground当中,组件1可以访问响应式num,但是在小程序uniapp里面这么写,不能够响应式
0 个回复