# mpx/valid-initdata

setup-script 和 普通模式下,检测动态数据是否有initData声明

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

# 📖 规则详情

<!-- 普通 --> <script> createComponent({ initData: { show: true, num: 0, inc: 0 }, computed: { ...store.mapState(['count', 'num']), inc() { return 0 } } }) </script> <!-- setup --> <script setup> import { ref } from '@mpx/core' const count = ref(0) const num = ref(0) const inc = () => { count.value++ } const show = true defineOptions({ initData: { show: true, num: 0, inc: 0 } }) defineExpose({ show, num, inc }) </script> <template> <view show="{{show}}" num="{{num}}" inc="{{inc}}" /> </template>
Now loading...

# 🔧 选项

无.

# 🔍 具体实现