# mpx/valid-setup-define-expose

setup-script模式下,template中使用的变量必须导出

  • ⚙️ 这条规则包含在"plugin:mpx/composition-api-essential"

# 📖 规则详情

<script setup> import { ref } from '@mpx/core' const count = ref(0) const num = ref(0) const inc = () => { count.value++ } const show = true defineExpose({ show, num, inc }) </script> <template> <!-- ✓ GOOD --> <view wx:if="{{show}}" num="{{num}}" bindtap="inc" /> <!-- ✗ BAD --> <view wx:if="{{noexpose}}" bindtap="method"> {{ error }} </view> </template>
Now loading...

# 🔧 选项

无.

# 🔍 具体实现