Notas de estudio de Vue (15) - propiedades calculadas _ abreviatura

Úselo cuando solo lea y no escriba

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>姓名案例-计算属性简写</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../js/vue.js"></script>
  
</head>
<body>
<!-- 准备一个容器 -->
<div id="root">
  姓:<input type="text" v-model="na"><br><br>
  名:<input type="text" v-model="me"><br><br>
  全名:<span>{
    
    {name}}</span>
</div>
 
<script type="text/javascript">
Vue.config.productionTip=false
Vue.config.keyCodes.huiche=13//定义了一个别名键
const vm=new Vue({
    el:'#root',
    data:{
        na:'张',
        me:'三'
    },
//   计算属性只读不改的情况
   computed:{
    name(){
        return this.na+'-'+this.me
    }
   }
})
 
</script>
</body>
</html>

Supongo que te gusta

Origin blog.csdn.net/weixin_54763080/article/details/128837249
Recomendado
Clasificación