Vue.js常用功能
1,解决页面代码闪现:
<style>
[v-cloak]{
display:none !important;
}
</style>
<div id=”indexVm” v-cloak>
2,点击事件:
<button class=”” v-on:click=”del(val.ordersn)”>删除</button>
data: {
XX : XX,
},
methods : {
del : function(id){
alert( id );
}
},
created: function() {
}
3,遍历:
<div id=”indexVm“>
<div v-for=”list in lists”>
<span>{{list.对象属性}}</span>
</div>
</div>
或者:
<div id=”indexVm“>
<div v-for=”(list,index) in lists”>
<span>{{list}}的索引值是{{index}}</span>
</div>
</div>
<script type=“text/javascript”>
new Vue({
el:“#indexVm“,
data:{
lists : []
},
created: function () {
XXXXXXXXXXXXXXXX
success: function (data) {
vm.lists=data.list;
}
}
});
</script>
4,a标签跳转:
<a class=”” v-bind:href=” ‘ XXX.html?参数=’ + val.ordersn(遍历的值.对象属性) “>
5,html跳转html解决中文乱码问题:
A页面跳转B页面
jump(encodeURI(“B.html?tel=”+tel+”&id=”+id+”&time=”+time));
6,html对请求路径的参数进行切割:
<script type=”text/javascript”>
var searchUrl =window.location.href;
var searchData =searchUrl.split(“=”);
var searchText =decodeURI(searchData[3]);
</script>
博客新手,待改进!