From c46df6f192fb7293a0af97b144fef4367696484a Mon Sep 17 00:00:00 2001 From: wangxiaoping <809126545@qq.com> Date: Tue, 20 Jul 2021 14:47:47 +0800 Subject: [PATCH] uni-modules --- uni_modules/uni-nav-bar/changelog.md | 10 + .../components/uni-nav-bar/uni-nav-bar.vue | 245 +++++++++++++ .../components/uni-nav-bar/uni-status-bar.vue | 25 ++ uni_modules/uni-nav-bar/package.json | 82 +++++ uni_modules/uni-nav-bar/readme.md | 67 ++++ uni_modules/uni-popup/changelog.md | 10 + .../components/uni-popup-dialog/keypress.js | 45 +++ .../uni-popup-dialog/uni-popup-dialog.vue | 244 +++++++++++++ .../uni-popup-message/uni-popup-message.vue | 138 ++++++++ .../uni-popup-share/uni-popup-share.vue | 165 +++++++++ .../components/uni-popup/keypress.js | 45 +++ .../uni-popup/components/uni-popup/message.js | 22 ++ .../uni-popup/components/uni-popup/popup.js | 50 +++ .../uni-popup/components/uni-popup/share.js | 16 + .../components/uni-popup/uni-popup.vue | 321 ++++++++++++++++++ uni_modules/uni-popup/package.json | 84 +++++ uni_modules/uni-popup/readme.md | 294 ++++++++++++++++ .../uni-segmented-control/changelog.md | 2 + .../uni-segmented-control.vue | 141 ++++++++ .../uni-segmented-control/package.json | 82 +++++ uni_modules/uni-transition/changelog.md | 2 + .../uni-transition/uni-transition.vue | 280 +++++++++++++++ uni_modules/uni-transition/package.json | 82 +++++ uni_modules/uni-transition/readme.md | 84 +++++ 24 files changed, 2536 insertions(+) create mode 100644 uni_modules/uni-nav-bar/changelog.md create mode 100644 uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue create mode 100644 uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar.vue create mode 100644 uni_modules/uni-nav-bar/package.json create mode 100644 uni_modules/uni-nav-bar/readme.md create mode 100644 uni_modules/uni-popup/changelog.md create mode 100644 uni_modules/uni-popup/components/uni-popup-dialog/keypress.js create mode 100644 uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue create mode 100644 uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.vue create mode 100644 uni_modules/uni-popup/components/uni-popup-share/uni-popup-share.vue create mode 100644 uni_modules/uni-popup/components/uni-popup/keypress.js create mode 100644 uni_modules/uni-popup/components/uni-popup/message.js create mode 100644 uni_modules/uni-popup/components/uni-popup/popup.js create mode 100644 uni_modules/uni-popup/components/uni-popup/share.js create mode 100644 uni_modules/uni-popup/components/uni-popup/uni-popup.vue create mode 100644 uni_modules/uni-popup/package.json create mode 100644 uni_modules/uni-popup/readme.md create mode 100644 uni_modules/uni-segmented-control/changelog.md create mode 100644 uni_modules/uni-segmented-control/components/uni-segmented-control/uni-segmented-control.vue create mode 100644 uni_modules/uni-segmented-control/package.json create mode 100644 uni_modules/uni-transition/changelog.md create mode 100644 uni_modules/uni-transition/components/uni-transition/uni-transition.vue create mode 100644 uni_modules/uni-transition/package.json create mode 100644 uni_modules/uni-transition/readme.md diff --git a/uni_modules/uni-nav-bar/changelog.md b/uni_modules/uni-nav-bar/changelog.md new file mode 100644 index 0000000..80fc4ba --- /dev/null +++ b/uni_modules/uni-nav-bar/changelog.md @@ -0,0 +1,10 @@ +## 1.0.8(2021-04-14) +- uni 修复 uni-nav-bar 当 fixed 属性为 true 时铺不满屏幕的 bug +## 1.0.7(2021-02-25) +- 修复 easycom 下,找不到 uni-status-bar 的bug + +## 1.0.6(2021-02-05) +- 优化 组件引用关系,通过uni_modules引用组件 + +## 1.0.5(2021-02-05) +- 调整为uni_modules目录规范 diff --git a/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue b/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue new file mode 100644 index 0000000..8d45c7b --- /dev/null +++ b/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue @@ -0,0 +1,245 @@ + + + + + diff --git a/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar.vue b/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar.vue new file mode 100644 index 0000000..47179d3 --- /dev/null +++ b/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar.vue @@ -0,0 +1,25 @@ + + + + + diff --git a/uni_modules/uni-nav-bar/package.json b/uni_modules/uni-nav-bar/package.json new file mode 100644 index 0000000..1cdfe75 --- /dev/null +++ b/uni_modules/uni-nav-bar/package.json @@ -0,0 +1,82 @@ +{ + "id": "uni-nav-bar", + "displayName": "NavBar 自定义导航栏", + "version": "1.0.8", + "description": "自定义导航栏组件,主要用于头部导航。", + "keywords": [ + "", + "nav-bar", + "title", + "自定义导航栏" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, + "dcloudext": { + "category": [ + "前端组件", + "通用组件" + ], + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y" + }, + "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", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-nav-bar/readme.md b/uni_modules/uni-nav-bar/readme.md new file mode 100644 index 0000000..920d6c5 --- /dev/null +++ b/uni_modules/uni-nav-bar/readme.md @@ -0,0 +1,67 @@ + + +### NavBar 导航栏 +*已经支持在nvue页面中使用* + +导航栏组件,主要用于头部导航,组件名:``uni-nav-bar``,代码块: uNavBar。 + +### 使用方式 + +在 ``script`` 中引用组件 + +```javascript +import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue' +export default { + components: {uniNavBar} +} +``` + +在 ``template`` 中使用组件 + +```html + +``` + +### 属性说明 + +|属性名 |类型 |默认值 |说明 | +|:-: |:-: |:-: |:-: | +|title |String |- |标题文字 | +|leftText |String |- |左侧按钮文本 | +|rightText |String |- |右侧按钮文本 | +|leftIcon |String |- |左侧按钮图标(图标类型参考 [Icon 图标](http://ext.dcloud.net.cn/plugin?id=28) type 属性) | +|rightIcon |String |- |右侧按钮图标(图标类型参考 [Icon 图标](http://ext.dcloud.net.cn/plugin?id=28) type 属性) | +|color |String |#000000|图标和文字颜色 | +|backgroundColor |String |#FFFFFF|导航栏背景颜色 | +|fixed |Boolean|false |是否固定顶部 | +|statusBar |Boolean|false |是否包含状态栏 | +|shadow |Boolean|false |导航栏下是否有阴影 | + +### 插槽说明 + +开发者使用 NavBar 时,支持向 NavBar 里插入不同内容,以达到自定义的目的。 + +|slot名 |说明 | +|:-: |:-: | +|left |向导航栏左侧插入 | +|right |向导航栏右侧插入 | +|default|向导航栏中间插入 | + +```html + + 标题栏 + left + right + +``` + +### 事件说明 + +|事件名 |说明 |返回值 | +|:-: |:-: |:-: | +|@clickLeft |左侧按钮点击时触发 |- | +|@clickRight |右侧按钮点击时触发 |- | + +### 插件预览地址 + +[https://uniapp.dcloud.io/h5/pages/extUI/nav-bar/nav-bar](https://uniapp.dcloud.io/h5/pages/extUI/nav-bar/nav-bar) \ No newline at end of file diff --git a/uni_modules/uni-popup/changelog.md b/uni_modules/uni-popup/changelog.md new file mode 100644 index 0000000..a01e690 --- /dev/null +++ b/uni_modules/uni-popup/changelog.md @@ -0,0 +1,10 @@ +## 1.3.0(2021-04-13) +修复某些情况下uni-popup-dialog输入框的值获取失败的问题 +## 1.2.9(2021-02-05) +- 优化 组件引用关系,通过uni_modules引用组件 +## 1.2.8(2021-02-05) +- 调整为uni_modules目录规范 +## 1.2.7(2021-02-05) +- 调整为uni_modules目录规范 +- 新增 支持 PC 端 +- 新增 uni-popup-message 、uni-popup-dialog扩展组件支持 PC 端 diff --git a/uni_modules/uni-popup/components/uni-popup-dialog/keypress.js b/uni_modules/uni-popup/components/uni-popup-dialog/keypress.js new file mode 100644 index 0000000..6ef26a2 --- /dev/null +++ b/uni_modules/uni-popup/components/uni-popup-dialog/keypress.js @@ -0,0 +1,45 @@ +// #ifdef H5 +export default { + name: 'Keypress', + props: { + disable: { + type: Boolean, + default: false + } + }, + mounted () { + const keyNames = { + esc: ['Esc', 'Escape'], + tab: 'Tab', + enter: 'Enter', + space: [' ', 'Spacebar'], + up: ['Up', 'ArrowUp'], + left: ['Left', 'ArrowLeft'], + right: ['Right', 'ArrowRight'], + down: ['Down', 'ArrowDown'], + delete: ['Backspace', 'Delete', 'Del'] + } + const listener = ($event) => { + if (this.disable) { + return + } + const keyName = Object.keys(keyNames).find(key => { + const keyName = $event.key + const value = keyNames[key] + return value === keyName || (Array.isArray(value) && value.includes(keyName)) + }) + if (keyName) { + // 避免和其他按键事件冲突 + setTimeout(() => { + this.$emit(keyName, {}) + }, 0) + } + } + document.addEventListener('keyup', listener) + this.$once('hook:beforeDestroy', () => { + document.removeEventListener('keyup', listener) + }) + }, + render: () => {} +} +// #endif diff --git a/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue b/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue new file mode 100644 index 0000000..2ba25f2 --- /dev/null +++ b/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue @@ -0,0 +1,244 @@ + + + + + \ No newline at end of file diff --git a/uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.vue b/uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.vue new file mode 100644 index 0000000..17b0211 --- /dev/null +++ b/uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.vue @@ -0,0 +1,138 @@ + + + + diff --git a/uni_modules/uni-popup/components/uni-popup-share/uni-popup-share.vue b/uni_modules/uni-popup/components/uni-popup-share/uni-popup-share.vue new file mode 100644 index 0000000..bba688b --- /dev/null +++ b/uni_modules/uni-popup/components/uni-popup-share/uni-popup-share.vue @@ -0,0 +1,165 @@ + + + + diff --git a/uni_modules/uni-popup/components/uni-popup/keypress.js b/uni_modules/uni-popup/components/uni-popup/keypress.js new file mode 100644 index 0000000..6ef26a2 --- /dev/null +++ b/uni_modules/uni-popup/components/uni-popup/keypress.js @@ -0,0 +1,45 @@ +// #ifdef H5 +export default { + name: 'Keypress', + props: { + disable: { + type: Boolean, + default: false + } + }, + mounted () { + const keyNames = { + esc: ['Esc', 'Escape'], + tab: 'Tab', + enter: 'Enter', + space: [' ', 'Spacebar'], + up: ['Up', 'ArrowUp'], + left: ['Left', 'ArrowLeft'], + right: ['Right', 'ArrowRight'], + down: ['Down', 'ArrowDown'], + delete: ['Backspace', 'Delete', 'Del'] + } + const listener = ($event) => { + if (this.disable) { + return + } + const keyName = Object.keys(keyNames).find(key => { + const keyName = $event.key + const value = keyNames[key] + return value === keyName || (Array.isArray(value) && value.includes(keyName)) + }) + if (keyName) { + // 避免和其他按键事件冲突 + setTimeout(() => { + this.$emit(keyName, {}) + }, 0) + } + } + document.addEventListener('keyup', listener) + this.$once('hook:beforeDestroy', () => { + document.removeEventListener('keyup', listener) + }) + }, + render: () => {} +} +// #endif diff --git a/uni_modules/uni-popup/components/uni-popup/message.js b/uni_modules/uni-popup/components/uni-popup/message.js new file mode 100644 index 0000000..0ff9a02 --- /dev/null +++ b/uni_modules/uni-popup/components/uni-popup/message.js @@ -0,0 +1,22 @@ +export default { + created() { + if (this.type === 'message') { + // 不显示遮罩 + this.maskShow = false + // 获取子组件对象 + this.childrenMsg = null + } + }, + methods: { + customOpen() { + if (this.childrenMsg) { + this.childrenMsg.open() + } + }, + customClose() { + if (this.childrenMsg) { + this.childrenMsg.close() + } + } + } +} diff --git a/uni_modules/uni-popup/components/uni-popup/popup.js b/uni_modules/uni-popup/components/uni-popup/popup.js new file mode 100644 index 0000000..8e02434 --- /dev/null +++ b/uni_modules/uni-popup/components/uni-popup/popup.js @@ -0,0 +1,50 @@ +import message from './message.js'; +// 定义 type 类型:弹出类型:top/bottom/center +const config = { + // 顶部弹出 + top: 'top', + // 底部弹出 + bottom: 'bottom', + // 居中弹出 + center: 'center', + // 消息提示 + message: 'top', + // 对话框 + dialog: 'center', + // 分享 + share: 'bottom', +} + +export default { + data() { + return { + config: config, + popupWidth: 0, + popupHeight: 0 + } + }, + mixins: [message], + computed: { + isDesktop() { + return this.popupWidth >= 500 && this.popupHeight >= 500 + } + }, + mounted() { + const fixSize = () => { + const { + windowWidth, + windowHeight, + windowTop + } = uni.getSystemInfoSync() + this.popupWidth = windowWidth + this.popupHeight = windowHeight + windowTop + } + fixSize() + // #ifdef H5 + window.addEventListener('resize', fixSize) + this.$once('hook:beforeDestroy', () => { + window.removeEventListener('resize', fixSize) + }) + // #endif + }, +} diff --git a/uni_modules/uni-popup/components/uni-popup/share.js b/uni_modules/uni-popup/components/uni-popup/share.js new file mode 100644 index 0000000..462bb83 --- /dev/null +++ b/uni_modules/uni-popup/components/uni-popup/share.js @@ -0,0 +1,16 @@ +export default { + created() { + if (this.type === 'share') { + // 关闭点击 + this.mkclick = false + } + }, + methods: { + customOpen() { + console.log('share 打开了'); + }, + customClose() { + console.log('share 关闭了'); + } + } +} diff --git a/uni_modules/uni-popup/components/uni-popup/uni-popup.vue b/uni_modules/uni-popup/components/uni-popup/uni-popup.vue new file mode 100644 index 0000000..e1e8d11 --- /dev/null +++ b/uni_modules/uni-popup/components/uni-popup/uni-popup.vue @@ -0,0 +1,321 @@ + + + + diff --git a/uni_modules/uni-popup/package.json b/uni_modules/uni-popup/package.json new file mode 100644 index 0000000..dba8bdb --- /dev/null +++ b/uni_modules/uni-popup/package.json @@ -0,0 +1,84 @@ +{ + "id": "uni-popup", + "displayName": "PopUp 弹出层", + "version": "1.3.0", + "description": " Popup 组件,提供常用的弹层", + "keywords": [ + "popup", + "uni-ui", + "弹出层", + "uni-popup" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, + "dcloudext": { + "category": [ + "前端组件", + "通用组件" + ], + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" + }, + "uni_modules": { + "dependencies": [ + "uni-transition" + ], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y" + }, + "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", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-popup/readme.md b/uni_modules/uni-popup/readme.md new file mode 100644 index 0000000..2a73557 --- /dev/null +++ b/uni_modules/uni-popup/readme.md @@ -0,0 +1,294 @@ + + +## Popup 弹出层 +> 代码块: `uPopup` +> 关联组件:`uni-transition`,`uni-popup-dialog`,`uni-popup-message`,`uni-popup-share` + + +弹出层组件,在应用中弹出一个消息提示窗口、提示框等 + + +> 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。 +> - 组件需要依赖 `sass` 插件 ,请自行手动安装 +> - `uni-popup-message` 、 `uni-popup-dialog` 等扩展ui组件,需要和 `uni-popup` 配套使用,暂不支持单独使用 +> - `nvue` 中使用 `uni-popup` 时,尽量将组件置于其他元素后面,避免出现层级问题 +> - `uni-popup` 并不能完全阻止页面滚动,可在打开 `uni-popup` 的时候手动去做一些处理,禁止页面滚动 +> - 如果需要在子扩展组件内关闭 `uni-popup` ,请使用扩展(provide/inject)方式,其他方式可能会出现不可预知问题 +> - 如果想在页面渲染完毕后就打开 `uni-popup` ,请在 `onReady` 或 `mounted` 生命周期内调用,确保组件渲染完毕 +> - 在微信小程序开发者工具中,启用真机调试,popup 会延时出现,是因为 setTimeout 在真机调试中的延时问题导致的,预览和发布小程序不会出现此问题 +> - 使用 `npm` 方式引入组件,如果确认引用正确,但是提示未注册组件或显示不正常,请尝试重新编译项目 +> - `uni-popup` 中尽量不要使用 `scroll-view` 嵌套过多的内容,可能会影响组件的性能,导致组件无法打开或者打开卡顿 +> - `uni-popup` 不会覆盖原生 tabbar 和原生导航栏 + + + +### 安装方式 + +本组件符合[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) + + +## 基本用法 + +```html + +底部弹出 Popup +``` + +```javascript +export default { + methods:{ + open(){ + // 通过组件定义的ref调用uni-popup方法 + this.$refs.popup.open() + } + } + +} + +``` + +## API + +### Popup Props + +| 属性名 | 类型 | 默认值 | 说明 | +| :-: | :-: | :-: | :-: | +| animation | Boolean |true | 是否开启动画 | +| type | String |center | 弹出方式 | +| maskClick | Boolean |true | 蒙版点击是否关闭弹窗 | + +#### Type Options + +| 属性名 | 说明 | +| :-: | :-: | +| top | 顶部弹出 | +| center | 居中弹出 | +| bottom | 底部弹出 | +| message | 预置样式 :消息提示 | +| dialog | 预置样式 :对话框 | +| share | 预置样式 :底部弹出分享示例 | + + +### Popup Methods + +|方法称名 |说明 |参数| +|:-: |:-: |:-:| +|open |打开弹出层 |- | +|close |关闭弹出层 |- | + + +### Popup Events + +|事件称名 |说明 |返回值 | +|:-: |:-: |:-: | +|change |组件状态发生变化触发 |e={show: true|false,type:当前模式} | + + +## 扩展组件说明 +`uni-popup` 其实并没有任何样式,只提供基础的动画效果,给用户一个弹出层解决方案,仅仅是这样并不能满足开发需求,所以我们提供了三种基础扩展样式 + +### uni-popup-message 提示信息 + +将 `uni-popup` 的`type`属性改为 `message`,并引入对应组件即可使用消息提示 ,*该组件不支持单独使用* + +**示例** + +```html + + + +``` + +### uni-popup-message 属性说明 + +| 属性名 | 类型 | 默认值 | 说明 | +| :-: | :-: | :-: | :-: | +| type | String |success| 消息提示主题,可选值: success/warn/info/error | +| message | String |- | 消息提示文字 | +| duration | Number |3000 | 消息显示时间,超过显示时间组件自动关闭,设置为0 将不会关闭,需手动调用 close 方法关闭 | + +### uni-popup-dialog 对话框 + +将 `uni-popup` 的`type`属性改为 `dialog`,并引入对应组件即可使用对话框 ,*该组件不支持单独使用* + +**示例** + +```html + + + +``` + +```javascript +export default { + methods:{ + /** + * 点击取消按钮触发 + * @param {Object} done + */ + close(done){ + // TODO 做一些其他的事情,before-close 为true的情况下,手动执行 done 才会关闭对话框 + // ... + done() + }, + /** + * 点击确认按钮触发 + * @param {Object} done + * @param {Object} value + */ + confirm(done,value){ + // 输入框的值 + console.log(value) + // TODO 做一些其他的事情,手动执行 done 才会关闭对话框 + // ... + done() + } + } +} +``` + +### uni-popup-dialog 属性说明 + +| 属性名 | 类型 | 默认值 | 说明 | +| :-: | :-: | :-: | :-: | +| type | String |success| 对话框标题主题,可选值: success/warn/info/error | +| mode | String |base | 对话框模式,可选值:base(提示对话框)/input(可输入对话框) | +| title | String |- | 对话框标题 | +| content | String |- | 对话框内容,base模式下生效 | +| value | String\Number |- | 输入框默认值,input模式下生效 | +| placeholder | String |- | 输入框提示文字,input模式下生效 | +| before-close | Boolean |false | 是否拦截取消按钮,如为true,则不会关闭对话框,关闭需要监听 dialog 的 close 事件,并执行 done()| + +#### dialog 事件说明 + +|事件称名 |说明 |返回值 | +|:-: |:-: |:-: | +|close |点击dialog取消按钮触发 |done:执行关闭对话框 | +|confirm |点击dialog确定按钮触发 |done:执行关闭对话框:value:input模式下输入框的值 | + + +### uni-popup-share 分享示例 + +分享示例,不作为最终可使用的组件,将 `uni-popup` 的 `type` 属性改为 `share`,并引入对应组件即可使用 ,*该组件不支持单独使用* + +**示例** + +```html + + + +``` + +### uni-popup-share 属性说明 + +| 属性名| 类型 | 默认值 | 说明 | +| :-: | :-: | :-: | :-: | +| title | String | | 分享弹窗标题 | + +### uni-popup-share 事件说明 + +|事件称名 |说明 |返回值 | +|:-: |:-: |:-: | +|select |选择触发 |e = {item,index}:所选参数,done:执行关闭窗口 | + +**Tips** +- share 分享组件,只是作为一个扩展示例,如果需要修改数据源,请到组件内修改 + +## 如何扩展自己的 uni-popup 弹出层样式? +`uni-popup` 组件内容是通过 `slot` 插槽的方式去实现的,所以这极大的方便了我们的扩展。 + +现在我们可以在不改动 `uni-popup` 组件主体的情况下,方便的去扩展我们自己的弹出层样式。 + +### 添加自定义类型 +如果要去扩展 `uni-popup`,我们需要把组件*引入本地*,才能去进行扩展。 + +组件放到本地后,在组件目录找到 `popup.js` ,在 `config` 变量中定义自己的类型,key 为当前要定义的类型,value 为弹出类型(top/bottom/center) +我们以 `uni-popup-share` 为例,看如何扩展一个`share` 底部分享的一个 `uni-popup` 子组件,代码参考 `uni-popup-share.vue`。 + +```javascript + +// popup.js +const config = { + // ... + // 分享 key:share 为我们定义的类型 value : 'bottom' 为弹出方向(top/bottom/center) + // 这样配置好之后,我们自定义的弹出层就会从底部弹出 + share:'bottom', +} + +``` + +### 创建扩展组件 + +在组件目录创建文件 ,例 `uni-popup-share/uni-popup-share.vue`,结构与其他组件没有区别。 + +在组件内直接编写样式逻辑即可,如需自定义效果更强,可以通过 props 接受页面参数。 + + +### 与父组件 `uni-popup` 进行通讯 + +组件通讯我们使用了 `provide/inject` , 具体逻辑我们不需要关心,只要在子组件配置 `inject` ,即可获取父组件方法变量等。 + +```javascript + +// uni-popup-share.vue +export default { + name: 'UniPopupShare', + props: { + title: { + type: String, + default: '分享到' + } + }, + // 直接把下面这一行代码,放到自己的组件内 + inject: ['popup'], + // ... + methons:{ + /** + * 定义的选择事件,选择内容后触发 + */ + select(item, index) { + // 将事件发送到页面,在页面进行监听 + this.$emit('select', { + item, + index + }, () => { + // 延迟操作,执行父组件的close事件,关闭弹出层 + this.popup.close() + }) + }, + /** + * 关闭窗口 + */ + close() { + // 执行父组件的close事件,关闭弹出层 + this.popup.close() + } + } +} +``` + + +### 使用自定义组件 + +通过上面几个步骤 ,我们就可以使用这个组件了,只需要把我们自定义的组件放置到 `uni-popup` 组件内即可 ,指定 `uni-popup` 的 `type` 为我们第一步定义好的 `share` + +```html + + + +``` + +之后就可以按照 `uni-popup` 的使用方式去打开关闭弹出层了。更多细节可以参考 `uni-popup-message` 和 `uni-popup-dialog`。 + + +**Tips** +- 如果扩展组件目录名和组件名不一致,可能不会被 `easycom` 正确引用,请配置`easycom`规则或修改组件名称 + +### 分享你的组件 + +通过组件扩展,你可以扩展出更丰富的弹出层样式,如果您想让更多人使用你定制的组件,或者您有更好的点子或更好的实现方式,欢迎给我们提交 [PR](https://github.com/dcloudio/uni-ui/pulls),如被采用,会合并到示例中。 + +在使用中如遇到无法解决的问题,请提 [Issues](https://github.com/dcloudio/uni-ui/issues) 给我们。 + diff --git a/uni_modules/uni-segmented-control/changelog.md b/uni_modules/uni-segmented-control/changelog.md new file mode 100644 index 0000000..aec4bdd --- /dev/null +++ b/uni_modules/uni-segmented-control/changelog.md @@ -0,0 +1,2 @@ +## 1.0.4(2021-02-05) +- 调整为uni_modules目录规范 diff --git a/uni_modules/uni-segmented-control/components/uni-segmented-control/uni-segmented-control.vue b/uni_modules/uni-segmented-control/components/uni-segmented-control/uni-segmented-control.vue new file mode 100644 index 0000000..19f1328 --- /dev/null +++ b/uni_modules/uni-segmented-control/components/uni-segmented-control/uni-segmented-control.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/uni_modules/uni-segmented-control/package.json b/uni_modules/uni-segmented-control/package.json new file mode 100644 index 0000000..f0b2e16 --- /dev/null +++ b/uni_modules/uni-segmented-control/package.json @@ -0,0 +1,82 @@ +{ + "id": "uni-segmented-control", + "displayName": "SegmentedControl 分段器", + "version": "1.0.4", + "description": "分段器由至少 2 个分段控件组成,用作不同视图的显示", + "keywords": [ + "分段器", + "SegmentedControl", + "segement", + "顶部选择" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, + "dcloudext": { + "category": [ + "前端组件", + "通用组件" + ], + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y" + }, + "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", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-transition/changelog.md b/uni_modules/uni-transition/changelog.md new file mode 100644 index 0000000..9274bef --- /dev/null +++ b/uni_modules/uni-transition/changelog.md @@ -0,0 +1,2 @@ +## 1.0.2(2021-02-05) +- 调整为uni_modules目录规范 diff --git a/uni_modules/uni-transition/components/uni-transition/uni-transition.vue b/uni_modules/uni-transition/components/uni-transition/uni-transition.vue new file mode 100644 index 0000000..1161634 --- /dev/null +++ b/uni_modules/uni-transition/components/uni-transition/uni-transition.vue @@ -0,0 +1,280 @@ + + + + + diff --git a/uni_modules/uni-transition/package.json b/uni_modules/uni-transition/package.json new file mode 100644 index 0000000..368bb85 --- /dev/null +++ b/uni_modules/uni-transition/package.json @@ -0,0 +1,82 @@ +{ + "id": "uni-transition", + "displayName": "Transition 过渡动画", + "version": "1.0.2", + "description": "元素的简单过渡动画", + "keywords": [ + "动画", + "过渡", + "uni-transition", + "过渡动画" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, + "dcloudext": { + "category": [ + "前端组件", + "通用组件" + ], + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y" + }, + "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", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-transition/readme.md b/uni_modules/uni-transition/readme.md new file mode 100644 index 0000000..2809bd0 --- /dev/null +++ b/uni_modules/uni-transition/readme.md @@ -0,0 +1,84 @@ + + +## Transition 过渡动画 +> 代码块: `uTransition` + + +元素的简单过渡动画,组件名:`uni-transition` + +### 安装方式 + +本组件符合[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 + +``` +``` javascript + +import uniTransition from '@/components/uni-transition/uni-transition.vue' +export default { + components: { + uniTransition + }, + data() { + return { + show: false, + } + }, + onLoad() {}, + methods: { + open(mode) { + this.show = !this.show + }, + change() { + console.log('触发动画') + } + } + } +``` + +## API + +### Transition Props + +|属性名 |类型 |默认值 |说明 | +|:-: |:-: |:-: |:-:| +|show |Boolean|false |控制组件显示或隐藏, | +|modeClass |Array |- |过渡动画类型 | +|duration |Number |300 |过渡动画持续时间 | +|styles |Object |- |组件样式,同 css 样式,注意带’-‘连接符的属性需要使用小驼峰写法如:`backgroundColor:red` | + +#### modeClass 类型说明 +**格式为** :`['fade','slide-top']` + +|属性名 |说明 | +|:-: |:-: | +|fade |渐隐渐出过渡 | +|slide-top |由上至下过渡 | +|slide-right |由右至左过渡 | +|slide-bottom |由下至上过渡 | +|slide-left |由左至右过渡 | +|zoom-in |由小到大过渡 | +|zoom-out |由大到小过渡 | + +**注意** + +组合使用时,同一种类型相反的过渡动画如(slide-top、slide-bottom)同时使用时,只有最后一个生效 + +### Transition Events + +|事件称名 |说明 |返回值 | +|:-: |:-: |:-: | +|click |点击组件触发 |- | +|change |过渡动画结束时触发 | e = {detail:true} |