<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<p>{{msg|test('不懂')|test1}}</p>
</div>
<script src="./vue.js"></script>
<script>
// 简单的过滤器
Vue.filter('test', function (val, i) {
return val.replace(/懂/g, i)
})
Vue.filter('test1', function (val) {
return val + '你说是吧?'
})
let vm = new Vue({
el: '#app',
data: {
msg: '这是一段非常优美的句子,懂得人自然都懂了。'
}
})
</script>
</body>
</html>