vue基础1---input\select\is(is解决组合标签渲染错位)

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>vue基础1</title>

    <script src="js/vue.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>

    <div id="app">

        <input type="text" v-model="msg">

        <h1>{{msg}}</h1>

        <button type="button" @click="changeEvent">修改msg</button>

        <button type="button" @click="changeEvent2">修改msg</button>

        <template style="display: none;">

            <h1 v-show="1>2">hhdhfd</h1>

        </template>

        <br/>

        <input type="radio" id="one" value="One" v-model="picked">

        <label for="one">One</label>

        <br>

        <input type="radio" id="two" value="Two" v-model="picked">

        <label for="two">Two</label>

        <br/>

        <span>Picked: {{ picked }}</span>

 

        <br/>

        <input type="checkbox" id="jack" value="Jack" v-model="checkedNames" >

        <label for="jack">Jack</label>

        <input type="checkbox" id="john" value="John" v-model="checkedNames">

        <label for="john">John</label>

        <input type="checkbox" id="mike" value="Mike" v-model="checkedNames">

        <label for="mike">Mike</label>

        <br/>

        <span>Checked names: {{ checkedNames }}</span>

        <br/>

        <select v-model="selected">

            <option disabled value="">请选择</option>

            <option 

            v-for="option in options"

            :value="option.value"

        >{{option.text}}</option>

        </select>

        <br/>

        <span>selected option: {{ selected }}</span>

        <br/>

        <select v-model="selectedDuox" multiple>

                <option disabled value="">请选择</option>

                <option 

                v-for="option in options"

                :value="option.value"

            >{{option.text}}</option>

            </select>

            <br/>

            <span>selectedDuox option: {{ selectedDuox }}</span>

        <br/>

        <input

            type="checkbox"

            v-model="toggle"

            :true-value="a"

            :false-value="b"

            >

            <br/>

        <span>toggle option: {{ toggle }}</span>

        <br/>

        <!--在组合标签中比如table,不通过动态组件来渲染模板的情况下会发生模板渲染错位的问题  -->

        <table>

            <test></test>

        </table>

        <br/>

     <!-- 用动态组件引入test -->

       <table>

            <tr is="test"></tr>

        </table>

    </div>

     <script>

         var test={

             template:`

             <tr><td>{{list[0]}}</td></tr>

             `,

             data:function(){

                    return{

                        list:["html","css","js"]

                    }

                }

         }

         let app=new Vue({

             el:'#app',

             components:{test},

             data:{

                 msg:'nihao',

                 picked:"one",

                 checkedNames:['Jack'],

                 selected:"AAA",

                 options:[

                     {text:'One',value:"AAA"},

                     {text:'Two',value:"BBB"},

                     {text:'Three',value:"CCC"}

                 ],

                 selectedDuox:["AAA"],

                 toggle:'iama',

                 a:"iama",

                 b:"iamb"

             },

             methods: {

                 changeEvent() {

                     this.msg="hello ni"

                 },

                 changeEvent2:()=> { console.log(this)}

             },

         })

        console.log(app)

    </script>

</body>

</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值