elementui的小demo
基于vue及elementui制作的小demo<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="w
·
基于vue及elementui制作的小demo
<!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" :show-stops="true" :range="true" :debounce=900></el-slider>
<el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/" :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" multiple :limit="3" :on-exceed="handleExceed" :file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
</el-upload>
</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);
}
},
handleRemove(file, fileList) {
console.log(file, fileList);
},
handlePreview(file) {
console.log(file);
},
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${ file.name }?`);
}
})
</script>
</html>
更多推荐
已为社区贡献1条内容
所有评论(0)