请陛下批阅
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>自定义私有指令</title>
<script src="../../vue/vue-v2.6.11.js"></script>
</head>
<body>
<div id="app">
<p v-fontweight="100" v-fontsize="'100px'">这是一个很粗的</p>
</div>
</body>
<script>
var vm = new Vue({
el: '#app',
data: {
},
methods: {
},
filters: {
},
directives: {
'fontweight': {
bind: function (el, binding) {
console.log(binding);
el.style.fontWeight = binding.value;
}
},
'fontsize': function (el, binding) {
el.style.fontSize = parseInt(binding.value) + 'px';
}
}
});
</script>
</html>