当前位置:   article > 正文

elementui的小demo_elementui demo

elementui demo

基于vue及elementui制作的小demo

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  9. <!-- 引入样式 -->
  10. <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  11. <!-- 引入组件库 -->
  12. <script src="https://unpkg.com/element-ui/lib/index.js"></script>
  13. <style>
  14. </style>
  15. </head>
  16. <body>
  17. <div id="app">
  18. <el-switch :v-model="value" :width=100 active-text="我是个伞兵!" inactive-text="我不是个伞兵"></el-switch>
  19. <el-button @click="foolish"> 我宣布个事</el-button>
  20. <el-slider :v-model="value1" :min="-100" :max="18" :show-input="true" :show-stops="true" :range="true" :debounce=900></el-slider>
  21. <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">
  22. <el-button size="small" type="primary">点击上传</el-button>
  23. <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
  24. </el-upload>
  25. </div>
  26. </body>
  27. <script>
  28. let vm = new Vue({
  29. el: "#app",
  30. data() {
  31. return {
  32. value: true,
  33. value1: true,
  34. };
  35. },
  36. methods: {
  37. foolish(e) {
  38. alert('我是个伞兵!');
  39. this.value = !this.value;
  40. console.log(e);
  41. }
  42. },
  43. handleRemove(file, fileList) {
  44. console.log(file, fileList);
  45. },
  46. handlePreview(file) {
  47. console.log(file);
  48. },
  49. handleExceed(files, fileList) {
  50. this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
  51. },
  52. beforeRemove(file, fileList) {
  53. return this.$confirm(`确定移除 ${ file.name }?`);
  54. }
  55. })
  56. </script>
  57. </html>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/300065
推荐阅读