练习elementui时  写出的代码vue提示数据类型错误,得到的只有string类型的值,通过最后发现需要在el标签组件的元素前加" : "冒号

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <style>

    </style>
</head>

<body>
    <div id="app">
        <el-switch :v-model="value" :width=100 active-text="我是个伞兵!" inactive-text="我不是个伞兵"></el-switch>
        <el-button @click="foolish"> 我宣布个事</el-button>

        <el-slider :v-model="value1" :min="-100" :max="18" :show-input="true"></el-slider>


    </div>

</body>
<script>
    let vm = new Vue({
        el: "#app",
        data() {
            return {
                value: true,
                value1: true,
            };
        },
        methods: {
            foolish(e) {
                alert('我是个伞兵!');
                this.value = !this.value;
                console.log(e);
            }
        },

    })
</script>

</html>

Logo

前往低代码交流专区

更多推荐