1. 程式人生 > >vue模板

vue模板

vue v-cloak v-once

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />

<title>模板</title>

</head>

<script type="text/javascript" src="js/vue.js" ></script>

<script>

window.onload = function(){

//配置是否允許檢查代碼,方便調試,生產環境中設置為false

Vue.config.devtools = true; //檢查代碼

Vue.config.productioinTip = false; //有強迫癥的,可以關掉生產中的提示信息

let vm = new Vue({

el: "#div1",

data:{

msg:‘hello world!!!‘

},

created:function(){

alert(1111);

}

});

}

</script>

<style type="text/css">

[v-cloak]{

display: none;

}

</style>

<body>

<div id="div1">

<input type="text" v-model="msg">

<h1>aaaa<span v-cloak>{{msg}}</span></h1> <!-- 防止msg-->

<h1 v-text="msg"></h1> <!--v-text 不能解析html代碼-->

<h1 v-html="msg"></h1> <!--v-html 可以解析html代碼-->

<h2 v-once>{{msg}}</h2> <!--只綁定一次,雙向綁定改變不了-->

<h3 v-pre>{{msg}}</h3> <!--當需要輸出{{}}時,可以不編譯{{}}符號,以文本形式輸出-->

</div>

</body>

</html>


本文出自 “Note” 博客,轉載請與作者聯系!

vue模板