想了個需求,如題目
data:
demo: 'bacdefghijk'
web:
<h1>{{str(demo)}}</h1>
methods:
str(value) { return value.replace(value.substring(3, value.length - 4), '****') }
也可以在computed中使用,但限於知識,無法做到復用
web:
<h1>{{str}}</h1>
computed:
str() { return this.demo.replace(this.demo.substring(3, this.demo.length - 4), '****') }
這個問題研究了一上午,尚未解出。如有理解的,歡迎指教
不勝感激,以上。