vhtml

注意这种方法在你无法保证绝对安全时不要使用,否则会造成SSR攻击

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<title>Document</title>
</head>
<body>
<div id="app">
<span v-html="h2"></span>
</div>
<script>
new Vue({
el:'#app',
data:{
h2:'<h2>hello world</h2>'
}
})

</script>

</body>
</html>

结果:
avatar

-------------本文结束感谢您的阅读-------------