<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>模板</title>
	<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
	<script>
		window.onload = function () {
			let vm = new Vue({
				el: '#app',
				data: {
					msg: '文本',
					msg2: '文本<b>html</b>',
				},
				created: function () {},
				methods: {

				},
				mounted() {
					this.msg = '测试'
				}
			});
		}
	</script>
	<style>
		/* 必须配置css样式,否则不生效 */
		[v-cloak] {
			display: none;
		}
	</style>
</head>

<body>
	<div id="app">
		<input type="text" v-model="msg">
		<!-- 用来解决可能会出现闪烁的问题 -->
		<h3>标题:<span v-cloak>{{msg}}</span></h3>
		<!-- v-text和v-html -->
		<h3 v-text='msg'></h3>
		{{msg}}
		<p v-html="msg2"></p>
		<!-- 只绑定一次 -->
		<p v-once>{{msg}}</p>
		<!-- 不编译,原样显示 -->
		<p v-pre>{{msg}}</p>
	</div>
</body>

</html>
Logo

前往低代码交流专区

更多推荐