首页 热点专区 义务教育 高等教育 出国留学 考研考公

vue中的v-distpicker插件,修改样式无效!

发布网友

我来回答

4个回答

懂视网

这篇文章主要介绍了详解VUE-地区选择器(V-Distpicker)组件使用心得,内容挺不错的,现在分享给大家,也给大家做个参考。

废话不多说,直接进入正题。

安装,引用,这些直接从官网拷贝来的,就不多说了。

1、安装

使用 npm 安装:

npm install v-distpicker --save

使用 yarn 安装

yarn add v-distpicker --save

2、使用

注册组件

注册全局组件

import VDistpicker from 'v-distpicker'
Vue.component('v-distpicker', VDistpicker);

注册组件

import VDistpicker from 'v-distpicker'
export default {
 components: { VDistpicker }
}

简单使用

基础

<v-distpicker></v-distpicker>

默认值

<v-distpicker province="广东省" city="广州市" area="海珠区"></v-distpicker>

移动端

<v-distpicker type="mobile"></v-distpicker>

3、下面是重点

获取选择的值

<template>
 <button @click="choose">点我选择区域</button>
 <p class="pwrap" v-if="show">
 <v-distpicker type="mobile" @province="onChangeProvince" @city="onChangeCity" @area="onChangeArea"></v-distpicker>
 </p>
</template>

在你引用 v-distpicker 的父组件里面定义几个方法来获取选择的值。

<script>
 import VDistpicker from 'v-distpicker'
 export default {
 name: 'getAddress',
 components: { VDistpicker },
 data() {
 return {
 show:false,
 }
 },
 methods: {
 choose(){
 this.show=!this.show
 },
 onChangeProvince(a){
 console.log(a) 
 },
 onChangeCity(a){
 console.log(a) 
 },
 onChangeArea(a){
 console.log(a) 
 this.show=false
 } 
 },
}

4、样式

你是不是感觉弹出的样式很丑?

OK,下面来改改样式

<style scoped>
 .pwrap{
 height: 400px;
 overflow-y: auto;
 position: fixed;
 left: 0;
 bottom: 0;
 width: 100%;
 }
 .pwrap>>>.distpicker-address-wrapper{
 color: #999;
 }
 .pwrap>>>.address-header{
 position: fixed;
 bottom: 400px;
 width: 100%;
 background: #000;
 color:#fff;
 }
 .pwrap>>>.address-header ul li{
 flex-grow: 1;
 text-align: center;
 }
 .pwrap>>>.address-header .active{
 color: #fff;
 border-bottom:#666 solid 8px
 }
 .pwrap>>>.address-container .active{
 color: #000;
 }

</style>

OK,我要说的完了。。以上只是抛砖引玉,谁有更多的使用心得,请不吝评论

热心网友

先安装
npm install swiper
再导入,那个 swiper 是 在浏览器环境的, 关于差异请看js 几种模块化支持的差异
import swiper from 'swiper'追问

这个已经是一个组件了。你说的这个swiper和我问的这个好像没看出来联系哦

热心网友

移动端可以加个type=“mobile”

热心网友

你这样式引入了吗?

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com