Home  >  Article  >  Web Front-end  >  How to splice strings in vue.js

How to splice strings in vue.js

coldplay.xixi
coldplay.xixiOriginal
2020-11-11 09:25:534853browse

How to splice strings in vue.js: First define variables in data, the code is [data(){return{a: 'A'}}]; then implement strings and variables by clicking buttons The splicing of a, the code is [].

How to splice strings in vue.js

The operating environment of this tutorial: windows10, vue2.5.2, this article is applicable to all brands of computers.

【Recommended related articles: vue.js

Method of splicing strings in vue.js:

Define variables in data:

data() {
  return {
    a: 'A'
  }
}

Concatenate strings and variables a by clicking buttons

<button @click=&#39;showMsg&#39;></button>
//vue
methods: {
  showMsg() {
    alert(`获取了${a}`);
  }
}

Note that there are not single quotes in alert(), but two ` signs (esc button below).

Click the button to appear

How to splice strings in vue.js

Related free learning recommendations: JavaScript (video)

The above is the detailed content of How to splice strings in vue.js. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn