init
This commit is contained in:
6
uni_modules/uni-breadcrumb/changelog.md
Normal file
6
uni_modules/uni-breadcrumb/changelog.md
Normal file
@ -0,0 +1,6 @@
|
||||
## 0.1.2(2022-06-08)
|
||||
- 修复 微信小程序 separator 不显示的Bug
|
||||
## 0.1.1(2022-06-02)
|
||||
- 新增 支持 uni.scss 修改颜色
|
||||
## 0.1.0(2022-04-21)
|
||||
- 初始化
|
@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<view class="uni-breadcrumb-item">
|
||||
<view :class="{
|
||||
'uni-breadcrumb-item--slot': true,
|
||||
'uni-breadcrumb-item--slot-link': to && currentPage !== to
|
||||
}" @click="navTo">
|
||||
<slot />
|
||||
</view>
|
||||
<i v-if="separatorClass" class="uni-breadcrumb-item--separator" :class="separatorClass" />
|
||||
<text v-else class="uni-breadcrumb-item--separator">{{ separator }}</text>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
/**
|
||||
* BreadcrumbItem 面包屑导航子组件
|
||||
* @property {String/Object} to 路由跳转页面路径/对象
|
||||
* @property {Boolean} replace 在使用 to 进行路由跳转时,启用 replace 将不会向 history 添加新记录(仅 h5 支持)
|
||||
*/
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
currentPage: ""
|
||||
}
|
||||
},
|
||||
options: {
|
||||
virtualHost: true
|
||||
},
|
||||
props: {
|
||||
to: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
replace:{
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
inject: {
|
||||
uniBreadcrumb: {
|
||||
from: "uniBreadcrumb",
|
||||
default: null
|
||||
}
|
||||
},
|
||||
created(){
|
||||
const pages = getCurrentPages()
|
||||
const page = pages[pages.length-1]
|
||||
|
||||
if(page){
|
||||
this.currentPage = `/${page.route}`
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
separator() {
|
||||
return this.uniBreadcrumb.separator
|
||||
},
|
||||
separatorClass() {
|
||||
return this.uniBreadcrumb.separatorClass
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
navTo() {
|
||||
const { to } = this
|
||||
|
||||
if (!to || this.currentPage === to){
|
||||
return
|
||||
}
|
||||
|
||||
if(this.replace){
|
||||
uni.redirectTo({
|
||||
url:to
|
||||
})
|
||||
}else{
|
||||
uni.navigateTo({
|
||||
url:to
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
$uni-primary: #2979ff !default;
|
||||
$uni-base-color: #6a6a6a !default;
|
||||
$uni-main-color: #3a3a3a !default;
|
||||
.uni-breadcrumb-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
white-space: nowrap;
|
||||
font-size: 14px;
|
||||
|
||||
&--slot {
|
||||
color: $uni-base-color;
|
||||
padding: 0 10px;
|
||||
|
||||
&-link {
|
||||
color: $uni-main-color;
|
||||
font-weight: bold;
|
||||
/* #ifndef APP-NVUE */
|
||||
cursor: pointer;
|
||||
/* #endif */
|
||||
|
||||
&:hover {
|
||||
color: $uni-primary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&--separator {
|
||||
font-size: 12px;
|
||||
color: $uni-base-color;
|
||||
}
|
||||
|
||||
&:first-child &--slot {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
&:last-child &--separator {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<view class="uni-breadcrumb">
|
||||
<slot />
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
/**
|
||||
* Breadcrumb 面包屑导航父组件
|
||||
* @description 显示当前页面的路径,快速返回之前的任意页面
|
||||
* @tutorial https://ext.dcloud.net.cn/plugin?id=xxx
|
||||
* @property {String} separator 分隔符,默认为斜杠'/'
|
||||
* @property {String} separatorClass 图标分隔符 class
|
||||
*/
|
||||
export default {
|
||||
options: {
|
||||
virtualHost: true
|
||||
},
|
||||
props: {
|
||||
separator: {
|
||||
type: String,
|
||||
default: '/'
|
||||
},
|
||||
separatorClass: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
|
||||
provide() {
|
||||
return {
|
||||
uniBreadcrumb: this
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.uni-breadcrumb {
|
||||
display: flex;
|
||||
}
|
||||
</style>
|
88
uni_modules/uni-breadcrumb/package.json
Normal file
88
uni_modules/uni-breadcrumb/package.json
Normal file
@ -0,0 +1,88 @@
|
||||
{
|
||||
"id": "uni-breadcrumb",
|
||||
"displayName": "uni-breadcrumb 面包屑",
|
||||
"version": "0.1.2",
|
||||
"description": "Breadcrumb 面包屑",
|
||||
"keywords": [
|
||||
"uni-breadcrumb",
|
||||
"breadcrumb",
|
||||
"uni-ui",
|
||||
"面包屑导航",
|
||||
"面包屑"
|
||||
],
|
||||
"repository": "",
|
||||
"engines": {
|
||||
"HBuilderX": "^3.1.0"
|
||||
},
|
||||
"directories": {
|
||||
"example": "../../temps/example_temps"
|
||||
},
|
||||
"dcloudext": {
|
||||
"category": [
|
||||
"前端组件",
|
||||
"通用组件"
|
||||
],
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "无",
|
||||
"permissions": "无"
|
||||
},
|
||||
"npmurl": ""
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": [],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "y",
|
||||
"aliyun": "y"
|
||||
},
|
||||
"client": {
|
||||
"Vue": {
|
||||
"vue2": "y",
|
||||
"vue3": "y"
|
||||
},
|
||||
"App": {
|
||||
"app-vue": "y",
|
||||
"app-nvue": "n"
|
||||
},
|
||||
"H5-mobile": {
|
||||
"Safari": "y",
|
||||
"Android Browser": "y",
|
||||
"微信浏览器(Android)": "y",
|
||||
"QQ浏览器(Android)": "y"
|
||||
},
|
||||
"H5-pc": {
|
||||
"Chrome": "y",
|
||||
"IE": "y",
|
||||
"Edge": "y",
|
||||
"Firefox": "y",
|
||||
"Safari": "y"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "y",
|
||||
"阿里": "u",
|
||||
"百度": "u",
|
||||
"字节跳动": "u",
|
||||
"QQ": "u",
|
||||
"京东": "u"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "u",
|
||||
"联盟": "u"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
66
uni_modules/uni-breadcrumb/readme.md
Normal file
66
uni_modules/uni-breadcrumb/readme.md
Normal file
@ -0,0 +1,66 @@
|
||||
|
||||
## breadcrumb 面包屑导航
|
||||
> **组件名:uni-breadcrumb**
|
||||
> 代码块: `ubreadcrumb`
|
||||
|
||||
显示当前页面的路径,快速返回之前的任意页面。
|
||||
|
||||
### 安装方式
|
||||
|
||||
本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`。
|
||||
|
||||
如需通过`npm`方式使用`uni-ui`组件,另见文档:[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55)
|
||||
|
||||
### 基本用法
|
||||
|
||||
在 ``template`` 中使用组件
|
||||
|
||||
```html
|
||||
<uni-breadcrumb separator="/">
|
||||
<uni-breadcrumb-item v-for="(route,index) in routes" :key="index" :to="route.to">{{route.name}}</uni-breadcrumb-item>
|
||||
</uni-breadcrumb>
|
||||
```
|
||||
|
||||
```js
|
||||
export default {
|
||||
name: "uni-stat-breadcrumb",
|
||||
data() {
|
||||
return {
|
||||
routes: [{
|
||||
to: '/A',
|
||||
name: 'A页面'
|
||||
}, {
|
||||
to: '/B',
|
||||
name: 'B页面'
|
||||
}, {
|
||||
to: '/C',
|
||||
name: 'C页面'
|
||||
}]
|
||||
};
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### Breadcrumb Props
|
||||
|
||||
|属性名 |类型 |默认值 |说明 |
|
||||
|:-: |:-: |:-: |:-: |
|
||||
|separator |String |斜杠'/' |分隔符 |
|
||||
|separatorClass |String | |图标分隔符 class |
|
||||
|
||||
### Breadcrumb Item Props
|
||||
|
||||
|属性名 |类型 |默认值 |说明 |
|
||||
|:-: |:-: |:-: |:-: |
|
||||
|to |String | |路由跳转页面路径 |
|
||||
|replace|Boolean | |在使用 to 进行路由跳转时,启用 replace 将不会向 history 添加新记录(仅 h5 支持) |
|
||||
|
||||
|
||||
|
||||
|
||||
## 组件示例
|
||||
|
||||
点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/breadcrumb/breadcrumb](https://hellouniapp.dcloud.net.cn/pages/extUI/breadcrumb/breadcrumb)
|
Reference in New Issue
Block a user