Element - The world's most popular Vue UI framework
<!-- Vue -->
<script src="<https://cdn.jsdelivr.net/npm/vue/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>
npm安装:npm i element-ui -S
全部导入:
import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue';
Vue.use(ElementUI);
new Vue({
el: '#app',
render: h => h(App)
});
如何使用?
只需要新创建一个组件,从官网上复制即可:
<template>
<el-switch
v-model="value"
active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</template>
<script>
export default {
data() {
return {
value: true
}
}
};
</script>