1、不安全的json值
undefined, function,symbol, 循环引用
JSON.stringify(undefined) // null
JSON.stringify(() => {}) // null
2、当设置整数的时可以这样,number修饰符会过滤掉小数点
<el-input size="small" v-model.number="proxyChannelData.proxy_price"></el-input>
// 两位小数
const re = /^(([1-9]{1}\d*)|(0{1}))(\.\d{0,2})?$/;
const check = (rule, value, callback) => {
if(isNaN(parseFloat(value))){
callback('请输入数字')
} else if(parseFloat(value) <= 0) {
callback('请输入大于0的数字')
} else if(parseFloat(value) > 99999999) {
callback(new Error(`最大值99999999`))
}else if(!re.test(value)) {
callback(new Error('请输入两位小数'))
} else {
callback()
}
}
'payment_price': [
{required: true, message: '请输入打款金额', trigger: ['blur', 'change']},
{type:'number', message: '请输入数字', trigger: 'change'},
{validator: check, trigger: 'change'}
],
3、mapState,mapMutations,mapActions
import {mapState, mapMutations, mapActions} from 'vuex'
computed: {
...mapState([''])
}
methods: {
...mapMutations(['FnMutation']),
...mapActions('FnAction')
}
mounted() {
this.FnAction()
}