Home >Web Front-end >Vue.js >How to use trim in vue
The trim method of Vue.js can remove the leading and trailing whitespace characters from the string. The usage is as follows: call the trim method directly. The trim method returns a new string with leading and trailing whitespace characters removed. The trim method only removes leading and trailing whitespace characters, not internal whitespace characters in the string. The trim method is immutable, i.e. it returns a new trimmed string and does not modify the original string.
The trim method in Vue.js
Overview
Vue.js The trim
method in is used to remove leading and trailing whitespace characters from a string.
Syntax
<code class="javascript">trim()</code>
Return value
A new string with leading and trailing whitespace characters removed.
Usage
Just call the trim
method directly.
<code class="javascript">// 原始字符串 const str = " Hello, world! " // 修剪字符串 const trimmedStr = str.trim() // 输出修剪后的字符串 console.log(trimmedStr) // Hello, world!</code>
Exampletrim
The method can be used to:
Note
trim
This method only removes the leading and trailing blank characters, but does not delete the blank characters inside the string. . trim
method will return the original string itself. trim
The method is immutable, i.e. it does not modify the original string but returns a new trimmed string. The above is the detailed content of How to use trim in vue. For more information, please follow other related articles on the PHP Chinese website!