菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Vue 测试实例 - 小鸟启蒙(facesoho.com)</title> <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script> </head> <body> <div id="app"> <div v-facesoho="{height:'33px',textAlign:'center',lineheight:'33px', background:'green', color:'#fff', text:'桃花潭水深千尺,不及汪伦送我情。 李白《赠汪伦》!' }"></div> </div> // 简写方式设置文本及背景颜色 <script> Vue.directive('facesoho', function (el, binding) { el.innerHTML = binding.value.text; el.style.height = binding.value.height; el.style.lineHeight = binding.value.lineheight; el.style.textAlign = binding.value.textAlign; el.style.color = binding.value.color; el.style.backgroundColor = binding.value.background; }) new Vue({ el:'#app' }) </script> </body> </html>
运行结果