$computed
计算属性传参
将计算属性的返回值改为函数,再进行传值操作
<h3 :zzc="test(1)"></h3>
export default {
computed: {
test () {
return function (value) {
const state = {
1: 'zz',
2: 'cc',
};
for (let i in state) {
if (Number(value) === Number(i)) {
return state[i];
}
return 'gg';
}
};
},
},
}