Files
geg-gas-web/docs/表单二开/6_只改JS不改模版的二开.md

32 lines
985 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 如何在二开中只修改脚本不修改模版
可以在继承SimpleFormSetup时不指定模版
```vue
<script>
// 注意这里继承的是SimpleFormSetup使用script setup写法的组件无法继承必须使用特别的版本
import SimpleFormSetup from '/@/components/SimpleForm/src/SimpleFormSetup.vue';
export default {
mixins: [SimpleFormSetup],
setup(props, ctx) {
const ret = SimpleFormSetup.setup(props, ctx);
return {
...ret
};
},
watch: {
formModel: {
handler: function(oldVal, newVal){
console.log('表单被改了!' + Math.random());
this.formModel.zheDie17153 = this.formModel.zhaGe15916 + this.formModel.zhaGe22645
},
deep: true
}
}
};
</script>
```
这里可以通过对formModel的监控和修改完成计算、赋值操作。