Vue.js动态绑定文本内容,绑定html以及其他属性
一、绑定属性或者html主要操作技能:v-bind:title 鼠标移上的显示v-bind:src 绑定图片路径v-bind:html绑定HTML文本和标签v-bind:text绑定文本v-bind:class 绑定类样式v-bind:style 动态绑定样式编写代码<div class="r...
·
一、绑定属性或者html
主要操作技能:
v-bind:title 鼠标移上的显示
v-bind:src 绑定图片路径
v-bind:html 绑定HTML文本和标签
v-bind:text 绑定文本
v-bind:class 绑定类样式
v-bind:style 动态绑定样式
编写代码
<div class="row mb-lg-4" v-html="content">
</div>
window.onload = function(){
new Vue({
el:'#container',
data:{
content:''
},
methods:{
sqShow:function(){
//诉求摘要展示
//发送get请求
this.$http.get('/front/sqzy').then(function(res){
this.content=res.body;
},function(){
console.log('请求失败处理');
});
}
}
});
}
二、绑定文本内容
<div id="vue_det">
<h1>site : {{site}}</h1>
<h1>url : {{url}}</h1>
<h1>{{details()}}</h1>
</div>
<script type="text/javascript">
var vm = new Vue({
el: '#vue_det',
data: {
site: "菜鸟教程",
url: "www.runoob.com",
alexa: "10000"
},
methods: {
details: function() {
return this.site + " - 学的不仅是技术,更是梦想!";
}
}
})
</script>
更多推荐
已为社区贡献6条内容
所有评论(0)