zoukankan      html  css  js  c++  java
  • Vue练习十一:02_05_函数传参改变Div任意属性的值

    Demo 在线地址:
    https://sx00xs.github.io/test/11/index.html
    ---------------------------------------------------------------
    ide: vscode
    文件格式:.vue
    解析:(待补)

    <template>
      <div id="app">
        <div class="outer">
          <p>
            <label>属性名:</label>
            <input type="text" v-model="attr">
          </p>
          <p>
            <label>属性值:</label>
            <input type="text" v-model="val">
          </p>
          <p>
            <label></label>
            <button @click="handleActive">确定</button>
            <button @click="handleReset">重置</button>
          </p>
        </div>
        <div :style="[baseStyles, overridingStyles]">在上方输入框输入"属性名"及"属性值",点击确定按钮查看效果。</div>
      </div>
    </template>
    <script>
    export default {
      data:function(){
        return{
          attr:'background',
          val:'blue',
          isActive:false,
          baseStyles:{
            color:'#fff',
            '180px',
            height:'180px',
            background:'#000',
            margin:'0 auto',
            padding:'10px',        
          }
        }
      },  
      computed:{
        overridingStyles(){
          var newAttr={};
          if(this.isActive){
            newAttr[this.attr]=this.val;
          }
          return newAttr;
        }
      },
      methods:{
        handleActive(){
          this.isActive=true;
        },
        handleReset(){
          this.isActive=false
        }
      }
    }
    </script>
  • 相关阅读:
    tcp/ip_properties_file
    tcp_ip/udp
    笔记1
    css样式使用_css
    常用的html标签总结_html
    利用sqlalchemy(ORM框架)连接操作mysql_mysql
    mysql基础命令_mysql
    redis使用_python
    RabitMQ使用_python
    后台管理页面2种常用模板_html
  • 原文地址:https://www.cnblogs.com/sx00xs/p/11265986.html
Copyright © 2011-2022 走看看