Home >Web Front-end >JS Tutorial >Computed properties and data monitoring in Vue.js

Computed properties and data monitoring in Vue.js

php中世界最好的语言
php中世界最好的语言Original
2018-03-13 14:13:031497browse

This time I will bring you the calculation properties and data monitoring of Vue.js. What are the precautions for Vue.js calculation properties and data monitoring. The following is a practical case. Let’s take a look.

Computed attribute computed
Requirement: Replace the numbers in the form input content

<template>
  <div id="myapp">
    {{myValueWithoutNum}}    <br>
    <input type="text" v-model="myValue">
  </div></template><script>
  export default {
    data () {      return {        myValue: &#39;&#39;
      }
    },//    计算属性
    computed: {
      myValueWithoutNum () {//        把输入的数字替换为空
        return this.myValue.replace(/\d/g, &#39;&#39;)
      }
    }
  }</script>

Computed properties and data monitoring in Vue.js

The above effect

The above is the detailed content of Computed properties and data monitoring 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