V1 version is based on Element-UI 2.x, which can be used by Element-UI 2.x; it can also be used independently, but it is necessary to introduce the corresponding style
V2 version is based on Element-Plus. It can be used by Element-Plus; it can also be used independently, but the corresponding style is introduced.
V1 version of the portal
V1 version, V2 version
It will not automatically inject CSS and need to be introduced manually to avoid style coverage; if the Element-Plus style is introduced globally, there is no additional introduction!
Local development mode, using the ESM module by default, if you need to rush into ES5, please refer to:
// 在 vue-cli 将指定的 node_modules 模块转义成es5:
// vue.config.js
module . exports = {
// 省略代码
transpileDependencies : [ 'date-week-range' , 'element-plus' ]
}
Install
npm install date-week-range@next --save
yarn add date-week-range@next --save
register
import DateWeekRange from 'date-week-range'
import { createApp } from 'vue'
// 引入样式;如果全局引入了 element-plus 样式,则无需再次引入
// 全局引入 element-plus 样式
// import 'element-plus/dist/index.css'
// 或引入
// import 'element-plus/theme-chalk/el-icon.css'
// import 'element-plus/theme-chalk/el-date-picker.css'
// import 'element-plus/theme-chalk/el-var.css';
// 或引入
// import 'date-week-range/index.css'
const app = createApp ( {
/* ... */
} )
app . use ( DateWeekRange )
< template >
< DateWeekRange v-model = "test" > </ DateWeekRange >
</ template >
< script >
import { DateWeekRange } from 'date-week-range'
// 注意要引入样式!引入方式参考上面
export default {
data ( ) {
return {
test : ''
}
} ,
components : {
DateWeekRange
}
}
< / script>
<!-- 引入样式。如果全局引入了element-plus 样式,则不需额外引入 -->
<!-- 全局引入 element-plus 样式 -->
< link type =" text/css " href =" https://unpkg.com/element-plus/lib/theme-chalk/index.css " >
<!-- 或者额外引入 -->
< link type =" text/css " href =" https://unpkg.com/element-plus/lib/theme-chalk/el-icon.css " >
< link type =" text/css " href =" https://unpkg.com/element-plus/lib/theme-chalk/el-date-picker.css " >
< script src =" https://unpkg.com/date-week-range@next " > </ script >
< body >
< div id =" app " >
< date-week-range v-model =" test " > </ date-week-range >
</ div >
</ body >
< script >
const app = window . Vue . createApp ( {
data ( ) {
return {
test : ''
}
}
} )
app . use ( window . DateWeekRange )
app . mount ( "#app" )
</ script >
Use Chinese default
Global registration
import { createApp } from 'vue'
import App from './App.vue'
import DateWeekRange from 'date-week-range'
import 'dayjs/locale/zh-cn'
import locale from 'element-plus/lib/locale/lang/zh-cn'
const app = createApp ( App )
app . use ( DateWeekRange , { locale } )
app . mount ( '#app' )
export default app
When registering
< script >
import { DateWeekRange , locale } from 'date-week-range'
import lang from 'element-plus/lib/locale/lang/zh-cn'
import 'dayjs/locale/zh-cn'
locale(lang)
/* 省略… */
</ script >
This plug-in is developed on the basis of the El-Date-Picker component in the Element-Plus framework, and its documentation is consistent with the El-Date-Picker component Type = "Daterant".