diff --git a/src/uni_modules/uview-plus/components/up-button/up-button.uvue b/src/uni_modules/uview-plus/components/up-button/up-button.uvue
index 4c38b3a04..32fab0c7d 100644
--- a/src/uni_modules/uview-plus/components/up-button/up-button.uvue
+++ b/src/uni_modules/uview-plus/components/up-button/up-button.uvue
@@ -111,7 +111,7 @@ import { throttle } from '../../libs/function/throttle';
export default {
name: "up-button",
// #ifdef MP
- mixins: [mpMixin, mixin, button, openType, propsButton],
+ mixins: [mpMixin, mixin, buttonMixin, openType, propsButton],
// #endif
// #ifndef MP
mixins: [mpMixin, mixin, propsButton],
@@ -153,7 +153,7 @@ export default {
? this.color
: config.getString(`color.up-${this.type}`) as String;
}
- if (this.type === "info") {
+ if (this.type == "info") {
return "#c9c9c9";
}
return "rgb(200, 200, 200)";
@@ -168,13 +168,13 @@ export default {
return "";
}
},
- baseColor(): any {
+ baseColor(): UTSJSONObject {
let style = {
color: ''
- };
+ } as UTSJSONObject;
if (this.color != '') {
// 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
- style.color = this.plain ? this.color : "white";
+ style['color'] = this.plain ? this.color : "white";
if (!this.plain) {
// 非镂空,背景色使用自定义的颜色
style["backgroundColor"] = this.color;
@@ -200,8 +200,8 @@ export default {
return style;
},
// nvue版本按钮的字体不会继承父组件的颜色,需要对每一个text组件进行单独的设置
- nvueTextStyle(): any {
- let style = {};
+ nvueTextStyle(): UTSJSONObject {
+ let style = {} as UTSJSONObject;
// 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
if (this.type === "info") {
style['color'] = "#323233";
diff --git a/src/uni_modules/uview-plus/components/up-col/col.uts b/src/uni_modules/uview-plus/components/up-col/col.uts
new file mode 100644
index 000000000..32442fd7e
--- /dev/null
+++ b/src/uni_modules/uview-plus/components/up-col/col.uts
@@ -0,0 +1,19 @@
+/*
+ * @Author : LQ,jry
+ * @Description :
+ * @version : 3.0
+ * @Date : 2021-08-20 16:44:21
+ * @LastAuthor : jry
+ * @lastTime : 2024-08-20 14:20:58
+ * @FilePath : /uview-plus/libs/config/props/col.js
+ */
+export default {
+ // col 组件
+ col: {
+ span: '12',
+ offset: '0',
+ justify: 'start',
+ align: 'stretch',
+ textAlign: 'left'
+ }
+} as UTSJSONObject
diff --git a/src/uni_modules/uview-plus/components/up-col/props.js b/src/uni_modules/uview-plus/components/up-col/props.js
index bd53fa6b5..3bbd8bd4c 100644
--- a/src/uni_modules/uview-plus/components/up-col/props.js
+++ b/src/uni_modules/uview-plus/components/up-col/props.js
@@ -1,6 +1,7 @@
import { defineMixin } from '../../libs/vue.js'
import defProps from '../../libs/config/props.js'
-export const props = defineMixin({
+
+export const propsCol = defineMixin({
props: {
// 占父容器宽度的多少等分,总分为12份
span: {
diff --git a/src/uni_modules/uview-plus/components/up-col/props.uts b/src/uni_modules/uview-plus/components/up-col/props.uts
new file mode 100644
index 000000000..cafd4bc90
--- /dev/null
+++ b/src/uni_modules/uview-plus/components/up-col/props.uts
@@ -0,0 +1,33 @@
+import { defineMixin } from '../../libs/vue'
+import defProps from './col'
+let crtProp = defProps['col'] as UTSJSONObject
+
+export const propsCol = defineMixin({
+ props: {
+ // 占父容器宽度的多少等分,总分为12份
+ span: {
+ type: [String, Number],
+ default: crtProp['span']
+ },
+ // 指定栅格左侧的间隔数(总12栏)
+ offset: {
+ type: [String, Number],
+ default: crtProp['offset']
+ },
+ // 水平排列方式,可选值为`start`(或`flex-start`)、`end`(或`flex-end`)、`center`、`around`(或`space-around`)、`between`(或`space-between`)
+ justify: {
+ type: String,
+ default: crtProp['justify']
+ },
+ // 垂直对齐方式,可选值为top、center、bottom、stretch
+ align: {
+ type: String,
+ default: crtProp['align']
+ },
+ // 文字对齐方式
+ textAlign: {
+ type: String,
+ default: crtProp['textAlign']
+ }
+ }
+})
diff --git a/src/uni_modules/uview-plus/components/up-col/up-col.uvue b/src/uni_modules/uview-plus/components/up-col/up-col.uvue
new file mode 100644
index 000000000..4e4d669fd
--- /dev/null
+++ b/src/uni_modules/uview-plus/components/up-col/up-col.uvue
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/uni_modules/uview-plus/components/up-col/up-col.vue b/src/uni_modules/uview-plus/components/up-col/up-col.vue
index 238f5b64a..403c3425d 100644
--- a/src/uni_modules/uview-plus/components/up-col/up-col.vue
+++ b/src/uni_modules/uview-plus/components/up-col/up-col.vue
@@ -13,7 +13,7 @@
+
+
diff --git a/src/uni_modules/uview-plus/components/up-row/up-row.vue b/src/uni_modules/uview-plus/components/up-row/up-row.vue
index 0c3b0e9b9..40ec1a10b 100644
--- a/src/uni_modules/uview-plus/components/up-row/up-row.vue
+++ b/src/uni_modules/uview-plus/components/up-row/up-row.vue
@@ -13,7 +13,7 @@
// #ifdef APP-NVUE
const dom = uni.requireNativePlugin('dom')
// #endif
- import { props } from './props.js';
+ import { propsRow } from './props.js';
import { mpMixin } from '../../libs/mixin/mpMixin.js';
import { mixin } from '../../libs/mixin/mixin.js';
import { addUnit, addStyle, deepMerge, sleep } from '../../libs/function/index.js';
@@ -31,7 +31,7 @@
*/
export default {
name: "up-row",
- mixins: [mpMixin, mixin, props],
+ mixins: [mpMixin, mixin, propsRow],
data() {
return {
diff --git a/src/uni_modules/uview-plus/libs/function/index.uts b/src/uni_modules/uview-plus/libs/function/index.uts
index 0ed2d303e..25cf1d70a 100644
--- a/src/uni_modules/uview-plus/libs/function/index.uts
+++ b/src/uni_modules/uview-plus/libs/function/index.uts
@@ -34,18 +34,18 @@ export function getPx(valueOri: any, unit = false): string {
return unit ? `${value}px` : (value)
}
-// /**
-// * @description 进行延时,以达到可以简写代码的目的 比如: await sleep(20)将会阻塞20ms
-// * @param {number} value 堵塞时间 单位ms 毫秒
-// * @returns {Promise} 返回promise
-// */
-// export function sleep(value = 30): any {
-// return new Promise((resolve) => {
-// setTimeout(() => {
-// resolve({})
-// }, value)
-// })
-// }
+/**
+ * @description 进行延时,以达到可以简写代码的目的 比如: await sleep(20)将会阻塞20ms
+ * @param {number} value 堵塞时间 单位ms 毫秒
+ * @returns {Promise} 返回promise
+ */
+export function sleep(value = 30): any {
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve({})
+ }, value)
+ })
+}
// /**
// * @description 运行期判断平台
// * @returns {string} 返回所在平台(小写)
@@ -109,25 +109,25 @@ export function getPx(valueOri: any, unit = false): string {
// return uuid.join('')
// }
-// /**
-// * @description 获取父组件的参数,因为支付宝小程序不支持provide/inject的写法
-// this.$parent在非H5中,可以准确获取到父组件,但是在H5中,需要多次this.$parent.$parent.xxx
-// 这里默认值等于undefined有它的含义,因为最顶层元素(组件)的$parent就是undefined,意味着不传name
-// 值(默认为undefined),就是查找最顶层的$parent
-// * @param {string|undefined} name 父组件的参数名
-// */
+/**
+* @description 获取父组件的参数,因为支付宝小程序不支持provide/inject的写法
+ this.$parent在非H5中,可以准确获取到父组件,但是在H5中,需要多次this.$parent.$parent.xxx
+ 这里默认值等于undefined有它的含义,因为最顶层元素(组件)的$parent就是undefined,意味着不传name
+ 值(默认为undefined),就是查找最顶层的$parent
+* @param {string|undefined} name 父组件的参数名
+*/
// export function $parent(name = ''): any {
-// // let parent = this.$parent
-// // // 通过while历遍,这里主要是为了H5需要多层解析的问题
-// // while (parent) {
-// // // 父组件
-// // if (parent.$options && parent.$options.name !== name) {
-// // // 如果组件的name不相等,继续上一级寻找
-// // parent = parent.$parent
-// // } else {
-// // return parent
-// // }
-// // }
+// let parent = this.$parent
+// // 通过while历遍,这里主要是为了H5需要多层解析的问题
+// while (parent) {
+// // 父组件
+// if (parent.$options && parent.$options.name !== name) {
+// // 如果组件的name不相等,继续上一级寻找
+// parent = parent.$parent
+// } else {
+// return parent
+// }
+// }
// return false
// }
@@ -341,15 +341,15 @@ export function error(err: string): void {
// 'h': date.getHours().toString().padStart(2, '0'), // 时
// 's': date.getSeconds().toString().padStart(2, '0') // 秒
// 有其他格式化字符需求可以继续添加,必须转化成字符串
- } as UTSJSONObject
- timeSource['y'] = date.getFullYear().toString()
- timeSource['m'] = (date.getMonth() as number + 1).toString().padStart(2, '0').toString()
- timeSource['d'] = date.getDate().toString().padStart(2, '0').toString()
- timeSource['M'] = date.getMinutes().toString().padStart(2, '0').toString()
- timeSource['h'] = date.getHours().toString().padStart(2, '0').toString()
- timeSource['s'] = date.getSeconds().toString().padStart(2, '0').toString()
-
- let timeSourceReturn = formatStr
+ } as UTSJSONObject
+ timeSource['y'] = date.getFullYear().toString()
+ timeSource['m'] = (date.getMonth() as number + 1).toString().padStart(2, '0').toString()
+ timeSource['d'] = date.getDate().toString().padStart(2, '0').toString()
+ timeSource['M'] = date.getMinutes().toString().padStart(2, '0').toString()
+ timeSource['h'] = date.getHours().toString().padStart(2, '0').toString()
+ timeSource['s'] = date.getSeconds().toString().padStart(2, '0').toString()
+
+ let timeSourceReturn = formatStr
// console.log(timeSource)
for (const key in timeSource) {
const ret = new RegExp(`${key}+`).exec(formatStr)
@@ -357,19 +357,19 @@ export function error(err: string): void {
// console.log('ret', ret)
// 年可能只需展示两位
const beginIndex = key === 'y' && ret.length === 2 ? 2 : 0
- if (timeSource != null
- && timeSource != null
- && timeSource[key] != null
- && key != '') {
- let replaceVal: string = ''
- let timeSourceKey = timeSource.getString(key)
- // console.log('timeSourceKey', typeof timeSourceKey)
- if (timeSourceKey != null) {
- replaceVal = timeSourceKey!!.slice(beginIndex)
- }
- timeSourceReturn = timeSourceReturn.replace(
- ret[0].toString(),
- replaceVal
+ if (timeSource != null
+ && timeSource != null
+ && timeSource[key] != null
+ && key != '') {
+ let replaceVal: string = ''
+ let timeSourceKey = timeSource.getString(key)
+ // console.log('timeSourceKey', typeof timeSourceKey)
+ if (timeSourceKey != null) {
+ replaceVal = timeSourceKey!!.slice(beginIndex)
+ }
+ timeSourceReturn = timeSourceReturn.replace(
+ ret[0].toString(),
+ replaceVal
)
}
}
@@ -565,18 +565,18 @@ export function priceFormat(numberOri: any, decimals = 0, decimalPoint = '.', th
const prec: number = !isFinite(decimals) ? 0 : Math.abs(decimals)
const sep = (typeof thousandsSeparator === 'undefined') ? ',' : thousandsSeparator
const dec = (typeof decimalPoint === 'undefined') ? '.' : decimalPoint
- let s: string[] = []
-
- if (prec > 0) {
- s = n.toString().split('.')
- s[1] = s[1].slice(0, prec)
- } else {
- s = (`${Math.round(n)}`).split('.')
+ let s: string[] = []
+
+ if (prec > 0) {
+ s = n.toString().split('.')
+ s[1] = s[1].slice(0, prec)
+ } else {
+ s = (`${Math.round(n)}`).split('.')
}
const re = /(-?\d+)(\d{3})/
while (re.test(s[0])) {
s[0] = s[0].replace(re, `$1${sep}$2`)
- }
+ }
if (s.length > 1) {
if ((s[1]).length < prec) {
s[1] = s[1]
@@ -736,6 +736,45 @@ export function formValidate(instance, event): void {
// // uni.$u.zIndex = deepMerge(uni.$u.zIndex, zIndex)
// }
+export function getParent(that: any, name = ''): any {
+ console.log('that', that)
+ let parent = that.$parent
+ // 通过while历遍,这里主要是为了H5需要多层解析的问题
+ while (parent) {
+ // 父组件
+ if (parent.$options && parent.$options.name !== name) {
+ // 如果组件的name不相等,继续上一级寻找
+ parent = parent.$parent
+ } else {
+ return parent
+ }
+ }
+ return false
+}
+export function getParentData(that: any, parentName: string): any {
+ console.log('that', JSON.stringify(that))
+ // 避免在created中去定义parent变量
+ //if (that.parent == null) that.parent = {}
+ // 这里的本质原理是,通过获取父组件实例(也即类似up-radio的父组件up-radio-group的this)
+ // 将父组件this中对应的参数,赋值给本组件(up-radio的this)的parentData对象中对应的属性
+ // 之所以需要这么做,是因为所有端中,头条小程序不支持通过this.parent.xxx去监听父组件参数的变化
+ // 此处并不会自动更新子组件的数据,而是依赖父组件up-radio-group去监听data的变化,手动调用更新子组件的方法去重新获取
+ // that.$data['parent'] = getParent(that, parentName)
+ // console.log('that.parent', that.parent)
+ // todo
+ // if (that.parent.children) {
+ // // 如果父组件的children不存在本组件的实例,才将本实例添加到父组件的children中
+ // that.parent.children.indexOf(that) === -1 && that.parent.children.push(that)
+ // }
+ // if (that.parent != null && that.parentData != null) {
+ // // 历遍parentData中的属性,将parent中的同名属性赋值给parentData
+ // UTSJSONObject.keys(that.parentData).map((key: string) => {
+ // that.parentData[key] = that.parent[key]
+ // })
+ // }
+ return {}
+}
+
export default {
// // range,
// // getPx,
diff --git a/src/uni_modules/uview-plus/libs/mixin/mixin.uts b/src/uni_modules/uview-plus/libs/mixin/mixin.uts
index 80b07b928..7938405d4 100644
--- a/src/uni_modules/uview-plus/libs/mixin/mixin.uts
+++ b/src/uni_modules/uview-plus/libs/mixin/mixin.uts
@@ -26,19 +26,17 @@ export const mixin = defineMixin({
default: 'navigateTo'
}
},
- // data() {
- // return {}
- // },
+ data() {
+ return {
+ parent: null as ComponentPublicInstance|null,
+ parentData: {} as UTSJSONObject
+ }
+ },
onLoad() {
- // getRect挂载到$u上,因为这方法需要使用in(this),所以无法把它独立成一个单独的文件导出
- // this.$u.getRect = this.$uGetRect
},
created() {
- // 组件当中,只有created声明周期,为了能在组件使用,故也在created中将方法挂载到$u
- // this.$u.getRect = this.$uGetRect
},
computed: {
-
},
methods: {
/**
@@ -94,62 +92,64 @@ export const mixin = defineMixin({
// 查询节点信息
// 目前此方法在支付宝小程序中无法获取组件跟接点的尺寸,为支付宝的bug(2020-07-21)
// 解决办法为在组件根部再套一个没有任何作用的view元素
- $uGetRect(selector: string, all: any) {
- // #ifndef APP-NVUE
- /**uni.createSelectorQuery()
- .in(this)[all ? 'selectAll' : 'select'](selector)
- .boundingClientRect((rect) => {
- if (all && Array.isArray(rect) && rect.length) {
- resolve(rect)
- }
- if (!all && rect) {
- resolve(rect)
- }
- })
- .exec()*/
- // #endif
-
- // #ifdef APP-NVUE
- /*
- sleep(30).then(() => {
- let selectorNvue = selector.substring(1) // 去掉开头的#或者.
- let selectorRef = this.$refs[selectorNvue]
- if (!selectorRef) {
- // console.log('不存在元素,请检查是否设置了ref属性' + selectorNvue + '。')
- resolve({
- with: 0,
- height: 0,
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- })
- }
- dom.getComponentRect(selectorRef, res => {
- // console.log(res)
- resolve(res.size)
- })
- })*/
- // #endif
+ upGetRect: function(selector: string): Promise {
+ return new Promise((resolve) => {
+ let tmp = {
+ width: 12
+ } as UTSJSONObject
+ resolve(tmp)
+ // uni.createSelectorQuery()
+ // .in(this)[all == true ? 'selectAll' : 'select'](selector)
+ // .boundingClientRect((rect) => {
+ // if (all && Array.isArray(rect) && rect.length) {
+ // resolve(rect)
+ // }
+ // if (!all && rect) {
+ // resolve(rect)
+ // }
+ // })
+ // .exec()
+ })
},
+ getParent(name: string): ComponentPublicInstance|null {
+ let parent = this.$parent
+ // 通过while历遍,这里主要是为了H5需要多层解析的问题
+ // while (parent) {
+ // // 父组件
+ // if (parent.$options && parent.$options.name !== name) {
+ // // 如果组件的name不相等,继续上一级寻找
+ // parent = parent.$parent
+ // } else {
+ // return parent
+ // }
+ // }
+ return parent
+ },
+ /**
+ * 获取父组件数据
+ * @author jry ijry@qq.com
+ * @param parentName 父组件名称如up-row
+ * @returns
+ */
getParentData: function(parentName: string): any {
// 避免在created中去定义parent变量
- // if (!this.parent) this.parent = {}
// 这里的本质原理是,通过获取父组件实例(也即类似up-radio的父组件up-radio-group的this)
// 将父组件this中对应的参数,赋值给本组件(up-radio的this)的parentData对象中对应的属性
// 之所以需要这么做,是因为所有端中,头条小程序不支持通过this.parent.xxx去监听父组件参数的变化
// 此处并不会自动更新子组件的数据,而是依赖父组件up-radio-group去监听data的变化,手动调用更新子组件的方法去重新获取
- // this.parent = uni.$u.$parent.call(this, parentName)
+ this.parent = this.getParent(parentName)
+ // console.log('this.parent', this.parent)
+ // todo
// if (this.parent.children) {
// // 如果父组件的children不存在本组件的实例,才将本实例添加到父组件的children中
// this.parent.children.indexOf(this) === -1 && this.parent.children.push(this)
// }
- // if (this.parent && this.parentData) {
- // // 历遍parentData中的属性,将parent中的同名属性赋值给parentData
- // Object.keys(this.parentData).map((key) => {
- // this.parentData[key] = this.parent[key]
- // })
- // }
+ if (this.parent != null) {
+ // 历遍parentData中的属性,将parent中的同名属性赋值给parentData
+ UTSJSONObject.keys(this.parentData).map((key: string) => {
+ this.parentData[key] = this.parent?.$props?.[key]
+ })
+ }
return {}
},
// 阻止事件冒泡
diff --git a/uni-app-x/pages.json b/uni-app-x/pages.json
index d77be871c..200901f1d 100644
--- a/uni-app-x/pages.json
+++ b/uni-app-x/pages.json
@@ -350,12 +350,15 @@
// "style": {
// "navigationBarTitleText": "阅读更多"
// }
- // }, {
- // "path": "layout/layout",
- // "style": {
- // "navigationBarTitleText": "布局"
- // }
- // }, {
+ // },
+ //
+ ,{
+ "path": "layout/layout",
+ "style": {
+ "navigationBarTitleText": "布局"
+ }
+ }
+ // , {
// "path": "indexList/indexList",
// "style": {
// "navigationBarTitleText": "索引列表"
diff --git a/uni-app-x/pages/componentsC/layout/layout.nvue b/uni-app-x/pages/componentsC/layout/layout.uvue
similarity index 93%
rename from uni-app-x/pages/componentsC/layout/layout.nvue
rename to uni-app-x/pages/componentsC/layout/layout.uvue
index 0bd6cecbc..c428729f6 100644
--- a/uni-app-x/pages/componentsC/layout/layout.nvue
+++ b/uni-app-x/pages/componentsC/layout/layout.uvue
@@ -3,7 +3,7 @@
基础使用
-
+
@@ -11,7 +11,7 @@
-
+
@@ -78,7 +78,7 @@
@@ -102,7 +102,7 @@