vue關於截取字符串並將字符串替換成指定格式


想了個需求,如題目

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), '****')
                }

這個問題研究了一上午,尚未解出。如有理解的,歡迎指教

不勝感激,以上。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM