# 指令

# v-waves 指令

赋予 el-button 点击效果

<template>
    <el-button v-waves>按钮</el-button>
</template>

<script>
export default {
    name: 'WavesDemo'
}
</script>
1
2
3
4
5
6
7
8
9
显示代码

# v-loadMore 指令

赋予 el-select 滚动加载的能力。

TIP

打开控制台查看

<template>
    <el-select v-loadMore="loadMore" value="">
        <el-option
            v-for="(item, index) in Array(20)"
            :key="index"
            :label="`选项${index}`"
            :value="index"
        ></el-option>
    </el-select>
</template>

<script>
export default {
    name: 'LoadMore',
    methods: {
        loadMore() {
            console.log('触底了')
        }
    }
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
显示代码

# v-dialogDrag 指令

赋予 el-dialog 拖拽的能力。

TIP

点击头部可以拖动位置

<template>
    <div>
        <el-button @click="dialogVisible = true">点我</el-button>

        <el-dialog
            v-dialogDrag
            title="提示"
            :visible.sync="dialogVisible"
            width="30%"
        >
            <span>这是一段信息</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="dialogVisible = false"
                    >确 定</el-button
                >
            </span>
        </el-dialog>
    </div>
</template>

<script>
export default {
    name: 'DialogDrag',
    data() {
        return {
            dialogVisible: false
        }
    }
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
显示代码

# v-dialogDragWidth 指令

赋予 el-dialog 拖动宽度能力。

TIP

拖动右侧边框可以改变宽度

<template>
    <div>
        <el-button @click="dialogVisible = true">点我</el-button>

        <el-dialog
            v-dialogDragWidth
            title="提示"
            :visible.sync="dialogVisible"
            width="30%"
        >
            <span>这是一段信息</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="dialogVisible = false"
                    >确 定</el-button
                >
            </span>
        </el-dialog>
    </div>
</template>

<script>
export default {
    name: 'DialogDragWidth',
    data() {
        return {
            dialogVisible: false
        }
    }
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
显示代码