vue字符串换行(绝对管用)

vue 中 用 {{}}  进行数据绑定的时候,如果我么你想让字符串换行是不生效的


解决办法,不用上边的方式进行数据绑定,用v-html标签代替{{}}

data中的str为 "<b>1111</b><br/>2222"

例1,<div>{{str}}<div>

    例1效果:

                         <i>1111</i><br/>2222

例2,<div v-html="str"><div>

    例2效果 

                        1111

                        2222



猜你喜欢

转载自blog.csdn.net/liuguochao1024/article/details/80228689