data(){return}requestText:""}].">
How to wrap lines in vue.js: Use [v-html] to display, the code is [
data(){return}requestText :""}].
The operating environment of this tutorial: windows10 system, vue2.9, this article is applicable to all brands of computers.
【Recommended related articles:vue.js】
Line wrapping method in vue.js:
Custom text is often encountered on the page. If the text is too long, it needs to be wrapped. In HTML, you can wrap it through the
tag, or you can wrap it through the \n swivel chair character. The following is in javascript and vue. Line breaks
Line breaks in javascript
var reg=new RegExp("\n","g"), str= res.data.replace(reg,"
"); $('.class').html(str);
Line breaks in vue
The above line breaks in vue are not It works, because in vue {{}} displays variables,
will be displayed as a string, and \n will be displayed as a space. Therefore, the content inside {{}} will be treated as an ordinary string. If you want to display line breaks, you can use v-html to display it.
* 以下requestText是变量* data(){ return{ requestText:"" } } **一下是从服务器获取的动态数据** let reg=new RegExp("\n","g"); let str= result.data.replace(reg,"
"); this.requestText=str;
Related free learning recommendations:JavaScript(video)
The above is the detailed content of How to wrap lines in vue.js. For more information, please follow other related articles on the PHP Chinese website!