input select 值得綁定與獲取


<div style="margin-top:100px">
    <!--Input 值得綁定-->
    <div id="app20">
        <input id="txt01" v-model="message" placeholder="請輸入..." />
        <span>{{ message }}</span>
        <textarea id="area" v-model="message2"></textarea>

        <!--單個復選框   true  false-->
        <input type="checkbox" id="c00" v-model="checked" />
        <span>{{ checked }}</span>


        <!--多個復選框綁定同一個數組即可    value的值得數組-->
        <label for="c01">選擇框1</label>
        <input type="checkbox" id="c01" value="c01" v-model="checkNames" />
        <label for="c02">選擇框2</label>
        <input type="checkbox" id="c02" value="c02" v-model="checkNames" />
        <label for="c03">選擇3</label>
        <input type="checkbox" id="c03" value="c03" v-model="checkNames" />
        <span>{{ checkNames }}</span>

        <!-- select 列表-->
        <select v-model="selected" name="fruit">
            <option v-for="va in Infos" v-bind:value="va.value">{{ va.obj }}</option>       
        </select>
        <span>{{ selected }}</span>
</div>
<button id="btn" onclick="getValue()">獲取值</button>

  

<script>
    new Vue({
        el: "#app20",
        data: {
            message: '',
            message2: 'hahah\r\n12324325',
            checkNames: [],
            checked: false,
            selected: '',
            Infos: [{ obj: 'asasa', value: '11'}, {obj:'fdfsd',value:'22'}]
        }

    })

    function getValue() {
        alert($("#txt01").val());

    }


</script>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM