Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
genary
uni-app
提交
bc0a4d43
U
uni-app
项目概览
genary
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bc0a4d43
编写于
11月 17, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp-weixin): properties default value
上级
35d77e03
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
173 addition
and
73 deletion
+173
-73
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+14
-2
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+21
-8
packages/uni-mp-baidu/dist/uni.mp.esm.js
packages/uni-mp-baidu/dist/uni.mp.esm.js
+12
-0
packages/uni-mp-core/src/index.ts
packages/uni-mp-core/src/index.ts
+1
-0
packages/uni-mp-core/src/runtime/util.ts
packages/uni-mp-core/src/runtime/util.ts
+10
-0
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
+12
-0
packages/uni-mp-lark/dist/uni.mp.esm.js
packages/uni-mp-lark/dist/uni.mp.esm.js
+17
-14
packages/uni-mp-qq/dist/uni.mp.esm.js
packages/uni-mp-qq/dist/uni.mp.esm.js
+12
-0
packages/uni-mp-toutiao/dist/uni.mp.esm.js
packages/uni-mp-toutiao/dist/uni.mp.esm.js
+17
-14
packages/uni-mp-toutiao/src/runtime/componentLifetimes.ts
packages/uni-mp-toutiao/src/runtime/componentLifetimes.ts
+8
-16
packages/uni-mp-vite/src/plugin/build.ts
packages/uni-mp-vite/src/plugin/build.ts
+6
-1
packages/uni-mp-vue/dist/vue.runtime.esm.js
packages/uni-mp-vue/dist/vue.runtime.esm.js
+5
-2
packages/uni-mp-vue/lib/vue.runtime.esm.js
packages/uni-mp-vue/lib/vue.runtime.esm.js
+4
-2
packages/uni-mp-vue/src/plugin.ts
packages/uni-mp-vue/src/plugin.ts
+1
-0
packages/uni-mp-weixin/dist/uni.mp.esm.js
packages/uni-mp-weixin/dist/uni.mp.esm.js
+12
-0
packages/uni-mp-weixin/src/runtime/lifetimes.ts
packages/uni-mp-weixin/src/runtime/lifetimes.ts
+4
-0
packages/uni-quickapp-webview/dist/uni.mp.esm.js
packages/uni-quickapp-webview/dist/uni.mp.esm.js
+17
-14
未找到文件。
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
bc0a4d43
...
...
@@ -5044,6 +5044,7 @@ var serviceContext = (function (vue) {
type: [Number, String],
},
};
const API_CLOSE_PREVIEW_IMAGE = 'closePreviewImage';
const API_GET_VIDEO_INFO = 'getVideoInfo';
const GetVideoInfoOptions = {
...
...
@@ -7500,6 +7501,16 @@ var serviceContext = (function (vue) {
});
resolve();
}, PreviewImageProtocol, PreviewImageOptions);
const closePreviewImage = defineAsyncApi(API_CLOSE_PREVIEW_IMAGE, (_, { resolve, reject }) => {
try {
// @ts-expect-error
plus.nativeUI.closePreviewImage();
resolve();
}
catch (error) {
reject();
}
});
let recorder;
let recording = false;
...
...
@@ -12904,6 +12915,7 @@ var serviceContext = (function (vue) {
getImageInfo: getImageInfo,
getVideoInfo: getVideoInfo,
previewImage: previewImage,
closePreviewImage: closePreviewImage,
getRecorderManager: getRecorderManager,
saveVideoToPhotosAlbum: saveVideoToPhotosAlbum,
saveImageToPhotosAlbum: saveImageToPhotosAlbum,
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
bc0a4d43
...
...
@@ -4783,6 +4783,7 @@ const PreviewImageProtocol = {
type: [Number, String]
}
};
const API_CLOSE_PREVIEW_IMAGE = "closePreviewImage";
const API_GET_VIDEO_INFO = "getVideoInfo";
const GetVideoInfoOptions = {
formatArgs: {
...
...
@@ -17036,23 +17037,34 @@ var ImagePreview = /* @__PURE__ */ defineSystemComponent({
}
});
let state$2 = null;
let imagePreviewInstance;
const closePreviewImageView = () => {
state$2 = null;
nextTick(() => {
imagePreviewInstance == null ? void 0 : imagePreviewInstance.unmount();
imagePreviewInstance = null;
});
};
const previewImage = /* @__PURE__ */ defineAsyncApi(API_PREVIEW_IMAGE, (args, { resolve }) => {
if (!state$2) {
state$2 = reactive(args);
nextTick(() => {
const app = createRootApp(ImagePreview, state$2, () => {
state$2 = null;
nextTick(() => {
app.unmount();
});
});
app.mount(ensureRoot("u-a-p"));
imagePreviewInstance = createRootApp(ImagePreview, state$2, closePreviewImageView);
imagePreviewInstance.mount(ensureRoot("u-a-p"));
});
} else {
extend(state$2, args);
}
resolve();
}, PreviewImageProtocol, PreviewImageOptions);
const closePreviewImage = /* @__PURE__ */ defineAsyncApi(API_CLOSE_PREVIEW_IMAGE, (_, { resolve, reject }) => {
if (imagePreviewInstance) {
closePreviewImageView();
resolve();
} else {
reject();
}
});
let videoInput = null;
const chooseVideo = /* @__PURE__ */ defineAsyncApi(API_CHOOSE_VIDEO, ({ sourceType, extension }, { resolve, reject }) => {
initI18nChooseFileMsgsOnce();
...
...
@@ -19746,6 +19758,7 @@ var api = {
chooseFile,
chooseImage,
previewImage,
closePreviewImage,
chooseVideo,
request,
downloadFile,
...
...
@@ -21863,4 +21876,4 @@ var index = /* @__PURE__ */ defineSystemComponent({
return openBlock(), createBlock("div", clazz, [loadingVNode]);
}
});
export { $emit, $off, $on, $once, index$8 as Ad, index$7 as AdContentPage, index$6 as AdDraw, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, index$y as Button, index$5 as Camera, index$w as Canvas, index$u as Checkbox, index$v as CheckboxGroup, index$a as CoverImage, index$b as CoverView, index$t as Editor, index$A as Form, index$s as Icon, index$r as Image, Input, index$z as Label, LayoutComponent, index$4 as LivePlayer, index$3 as LivePusher, Map$1 as Map, MovableArea, MovableView, index$q as Navigator, index$2 as PageComponent, index$9 as Picker, PickerView, PickerViewColumn, index$p as Progress, index$n as Radio, index$o as RadioGroup, ResizeSensor, index$m as RichText, ScrollView, index$l as Slider, Swiper, SwiperItem, index$k as Switch, index$j as Text, index$i as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$e as Video, index$h as View, index$d as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getClipboardData, getCurrentPages$1 as getCurrentPages, getEnterOptionsSync, getFileInfo, getImageInfo, getLaunchOptionsSync, getLeftWindowStyle, getLocale, getLocation, getNetworkType, getProvider, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, interceptors, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onAppLaunch, onCompassChange, onGyroscopeChange, onLocaleChange, onMemoryWarning, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$f as plugin, preloadPage, previewImage, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setClipboardData, setKeepScreenOn, setLeftWindowStyle, setLocale, setNavigationBarColor, setNavigationBarTitle, setPageMeta, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useI18n, useTabBar, vibrateLong, vibrateShort };
export { $emit, $off, $on, $once, index$8 as Ad, index$7 as AdContentPage, index$6 as AdDraw, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, index$y as Button, index$5 as Camera, index$w as Canvas, index$u as Checkbox, index$v as CheckboxGroup, index$a as CoverImage, index$b as CoverView, index$t as Editor, index$A as Form, index$s as Icon, index$r as Image, Input, index$z as Label, LayoutComponent, index$4 as LivePlayer, index$3 as LivePusher, Map$1 as Map, MovableArea, MovableView, index$q as Navigator, index$2 as PageComponent, index$9 as Picker, PickerView, PickerViewColumn, index$p as Progress, index$n as Radio, index$o as RadioGroup, ResizeSensor, index$m as RichText, ScrollView, index$l as Slider, Swiper, SwiperItem, index$k as Switch, index$j as Text, index$i as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$e as Video, index$h as View, index$d as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, close
PreviewImage, close
Socket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getClipboardData, getCurrentPages$1 as getCurrentPages, getEnterOptionsSync, getFileInfo, getImageInfo, getLaunchOptionsSync, getLeftWindowStyle, getLocale, getLocation, getNetworkType, getProvider, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, interceptors, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onAppLaunch, onCompassChange, onGyroscopeChange, onLocaleChange, onMemoryWarning, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$f as plugin, preloadPage, previewImage, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setClipboardData, setKeepScreenOn, setLeftWindowStyle, setLocale, setNavigationBarColor, setNavigationBarTitle, setPageMeta, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useI18n, useTabBar, vibrateLong, vibrateShort };
packages/uni-mp-baidu/dist/uni.mp.esm.js
浏览文件 @
bc0a4d43
...
...
@@ -546,6 +546,16 @@ function handleEvent(event) {
}
this
[
methodName
](
event
);
}
/**
* @param properties
*/
function
fixProperties
(
properties
)
{
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
;
}
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
...
...
@@ -931,6 +941,8 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions, }) {
// 初始化 vue 实例
const
mpInstance
=
this
;
const
isMiniProgramPage
=
isPage
(
mpInstance
);
// 微信小程序 properties 为了解决警告问题,目前所有 type 都默认为 null,故导致部分 prop 默认值初始化不正确,故将 null 值 替换为 undefined
fixProperties
(
properties
);
this
.
$vm
=
$createComponent
({
type
:
vueOptions
,
props
:
properties
,
...
...
packages/uni-mp-core/src/index.ts
浏览文件 @
bc0a4d43
...
...
@@ -30,6 +30,7 @@ export {
initWxsCallMethods
,
findVmByVueId
,
handleEvent
,
fixProperties
,
}
from
'
./runtime/util
'
// protocols
...
...
packages/uni-mp-core/src/runtime/util.ts
浏览文件 @
bc0a4d43
...
...
@@ -166,3 +166,13 @@ export function handleEvent(
}
;(
this
as
any
)[
methodName
](
event
)
}
/**
* @param properties
*/
export
function
fixProperties
(
properties
:
Record
<
string
,
any
>
)
{
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
}
})
}
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
浏览文件 @
bc0a4d43
...
...
@@ -541,6 +541,16 @@ function handleEvent(event) {
}
this
[
methodName
](
event
);
}
/**
* @param properties
*/
function
fixProperties
(
properties
)
{
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
;
}
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
...
...
@@ -858,6 +868,8 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions, }) {
// 初始化 vue 实例
const
mpInstance
=
this
;
const
isMiniProgramPage
=
isPage
(
mpInstance
);
// 微信小程序 properties 为了解决警告问题,目前所有 type 都默认为 null,故导致部分 prop 默认值初始化不正确,故将 null 值 替换为 undefined
fixProperties
(
properties
);
this
.
$vm
=
$createComponent
({
type
:
vueOptions
,
props
:
properties
,
...
...
packages/uni-mp-lark/dist/uni.mp.esm.js
浏览文件 @
bc0a4d43
...
...
@@ -514,6 +514,16 @@ function findVmByVueId(instance, vuePid) {
}
}
}
/**
* @param properties
*/
function
fixProperties
(
properties
)
{
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
;
}
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
...
...
@@ -917,6 +927,13 @@ function initLifetimes$1({ mocks, isPage, initRelation, vueOptions, }) {
if
(
mpType
===
'
page
'
&&
!
mpInstance
.
route
&&
mpInstance
.
__route__
)
{
mpInstance
.
route
=
mpInstance
.
__route__
;
}
// 字节跳动小程序 properties
// 父组件在 attached 中 setData 设置了子组件的 props,在子组件的 attached 中,并不能立刻拿到
// 此时子组件的 properties 中获取到的值,除了一部分初始化就有的值,只要在模板上绑定了,动态设置的 prop 的值均会根据类型返回,不会应用 prop 自己的默认值
// 举例: easyinput 的 styles 属性,类型为 Object,`<easyinput :styles="styles"/>` 在 attached 中 styles 的值为 null
// 目前 null 值会影响 render 函数执行,临时解决方案,调整 properties 中的 null 值为 undefined,让 Vue 来补充为默认值
// 已知的其他隐患,当使用默认值时,可能组件行为不正确,比如 countdown 组件,默认值是0,导致直接就触发了 timeup 事件,这个应该是组件自身做处理?
// 难道要等父组件首次 setData 完成后,再去执行子组件的初始化?
fixProperties
(
properties
);
this
.
$vm
=
$createComponent
({
type
:
vueOptions
,
...
...
@@ -942,20 +959,6 @@ function initLifetimes$1({ mocks, isPage, initRelation, vueOptions, }) {
return
{
attached
,
detached
};
}
}
function
fixProperties
(
properties
)
{
// 字节跳动小程序 properties
// 父组件在 attached 中 setData 设置了子组件的 props,在子组件的 attached 中,并不能立刻拿到
// 此时子组件的 properties 中获取到的值,除了一部分初始化就有的值,只要在模板上绑定了,动态设置的 prop 的值均会根据类型返回,不会应用 prop 自己的默认值
// 举例: easyinput 的 styles 属性,类型为 Object,`<easyinput :styles="styles"/>` 在 attached 中 styles 的值为 null
// 目前 null 值会影响 render 函数执行,临时解决方案,调整 properties 中的 null 值为 undefined,让 Vue 来补充为默认值
// 已知的其他隐患,当使用默认值时,可能组件行为不正确,比如 countdown 组件,默认值是0,导致直接就触发了 timeup 事件,这个应该是组件自身做处理?
// 难道要等父组件首次 setData 完成后,再去执行子组件的初始化?
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
;
}
});
}
const
mocks
=
[
'
__route__
'
,
...
...
packages/uni-mp-qq/dist/uni.mp.esm.js
浏览文件 @
bc0a4d43
...
...
@@ -511,6 +511,16 @@ function findVmByVueId(instance, vuePid) {
}
}
}
/**
* @param properties
*/
function
fixProperties
(
properties
)
{
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
;
}
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
...
...
@@ -820,6 +830,8 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions, }) {
// 初始化 vue 实例
const
mpInstance
=
this
;
const
isMiniProgramPage
=
isPage
(
mpInstance
);
// 微信小程序 properties 为了解决警告问题,目前所有 type 都默认为 null,故导致部分 prop 默认值初始化不正确,故将 null 值 替换为 undefined
fixProperties
(
properties
);
this
.
$vm
=
$createComponent
({
type
:
vueOptions
,
props
:
properties
,
...
...
packages/uni-mp-toutiao/dist/uni.mp.esm.js
浏览文件 @
bc0a4d43
...
...
@@ -514,6 +514,16 @@ function findVmByVueId(instance, vuePid) {
}
}
}
/**
* @param properties
*/
function
fixProperties
(
properties
)
{
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
;
}
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
...
...
@@ -917,6 +927,13 @@ function initLifetimes$1({ mocks, isPage, initRelation, vueOptions, }) {
if
(
mpType
===
'
page
'
&&
!
mpInstance
.
route
&&
mpInstance
.
__route__
)
{
mpInstance
.
route
=
mpInstance
.
__route__
;
}
// 字节跳动小程序 properties
// 父组件在 attached 中 setData 设置了子组件的 props,在子组件的 attached 中,并不能立刻拿到
// 此时子组件的 properties 中获取到的值,除了一部分初始化就有的值,只要在模板上绑定了,动态设置的 prop 的值均会根据类型返回,不会应用 prop 自己的默认值
// 举例: easyinput 的 styles 属性,类型为 Object,`<easyinput :styles="styles"/>` 在 attached 中 styles 的值为 null
// 目前 null 值会影响 render 函数执行,临时解决方案,调整 properties 中的 null 值为 undefined,让 Vue 来补充为默认值
// 已知的其他隐患,当使用默认值时,可能组件行为不正确,比如 countdown 组件,默认值是0,导致直接就触发了 timeup 事件,这个应该是组件自身做处理?
// 难道要等父组件首次 setData 完成后,再去执行子组件的初始化?
fixProperties
(
properties
);
this
.
$vm
=
$createComponent
({
type
:
vueOptions
,
...
...
@@ -958,20 +975,6 @@ function initLifetimes$1({ mocks, isPage, initRelation, vueOptions, }) {
detached
,
};
}
function
fixProperties
(
properties
)
{
// 字节跳动小程序 properties
// 父组件在 attached 中 setData 设置了子组件的 props,在子组件的 attached 中,并不能立刻拿到
// 此时子组件的 properties 中获取到的值,除了一部分初始化就有的值,只要在模板上绑定了,动态设置的 prop 的值均会根据类型返回,不会应用 prop 自己的默认值
// 举例: easyinput 的 styles 属性,类型为 Object,`<easyinput :styles="styles"/>` 在 attached 中 styles 的值为 null
// 目前 null 值会影响 render 函数执行,临时解决方案,调整 properties 中的 null 值为 undefined,让 Vue 来补充为默认值
// 已知的其他隐患,当使用默认值时,可能组件行为不正确,比如 countdown 组件,默认值是0,导致直接就触发了 timeup 事件,这个应该是组件自身做处理?
// 难道要等父组件首次 setData 完成后,再去执行子组件的初始化?
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
;
}
});
}
const
mocks
=
[
'
__route__
'
,
...
...
packages/uni-mp-toutiao/src/runtime/componentLifetimes.ts
浏览文件 @
bc0a4d43
...
...
@@ -5,6 +5,7 @@ import {
MPComponentInstance
,
CreateComponentOptions
,
CreateLifetimesOptions
,
fixProperties
,
}
from
'
@dcloudio/uni-mp-core
'
import
{
...
...
@@ -42,7 +43,13 @@ export function initLifetimes({
if
(
mpType
===
'
page
'
&&
!
mpInstance
.
route
&&
mpInstance
.
__route__
)
{
mpInstance
.
route
=
mpInstance
.
__route__
}
// 字节跳动小程序 properties
// 父组件在 attached 中 setData 设置了子组件的 props,在子组件的 attached 中,并不能立刻拿到
// 此时子组件的 properties 中获取到的值,除了一部分初始化就有的值,只要在模板上绑定了,动态设置的 prop 的值均会根据类型返回,不会应用 prop 自己的默认值
// 举例: easyinput 的 styles 属性,类型为 Object,`<easyinput :styles="styles"/>` 在 attached 中 styles 的值为 null
// 目前 null 值会影响 render 函数执行,临时解决方案,调整 properties 中的 null 值为 undefined,让 Vue 来补充为默认值
// 已知的其他隐患,当使用默认值时,可能组件行为不正确,比如 countdown 组件,默认值是0,导致直接就触发了 timeup 事件,这个应该是组件自身做处理?
// 难道要等父组件首次 setData 完成后,再去执行子组件的初始化?
fixProperties
(
properties
)
this
.
$vm
=
$createComponent
(
...
...
@@ -98,18 +105,3 @@ export function initLifetimes({
detached
,
}
}
function
fixProperties
(
properties
:
Record
<
string
,
any
>
)
{
// 字节跳动小程序 properties
// 父组件在 attached 中 setData 设置了子组件的 props,在子组件的 attached 中,并不能立刻拿到
// 此时子组件的 properties 中获取到的值,除了一部分初始化就有的值,只要在模板上绑定了,动态设置的 prop 的值均会根据类型返回,不会应用 prop 自己的默认值
// 举例: easyinput 的 styles 属性,类型为 Object,`<easyinput :styles="styles"/>` 在 attached 中 styles 的值为 null
// 目前 null 值会影响 render 函数执行,临时解决方案,调整 properties 中的 null 值为 undefined,让 Vue 来补充为默认值
// 已知的其他隐患,当使用默认值时,可能组件行为不正确,比如 countdown 组件,默认值是0,导致直接就触发了 timeup 事件,这个应该是组件自身做处理?
// 难道要等父组件首次 setData 完成后,再去执行子组件的初始化?
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
}
})
}
packages/uni-mp-vite/src/plugin/build.ts
浏览文件 @
bc0a4d43
...
...
@@ -34,8 +34,13 @@ export function buildOptions(): UserConfig['build'] {
// sourcemap: 'inline', // TODO
// target: ['chrome53'], // 由小程序自己启用 es6 编译
emptyOutDir
:
false
,
// 不清空输出目录,否则会影响自定义的一些文件输出,比如wxml
lib
:
{
// 必须使用 lib 模式,否则会生成 preload 等代码
fileName
:
'
app.js
'
,
entry
:
resolveMainPathOnce
(
inputDir
),
formats
:
[
'
cjs
'
],
},
rollupOptions
:
{
input
:
resolveMainPathOnce
(
inputDir
),
output
:
{
entryFileNames
:
'
app.js
'
,
format
:
'
cjs
'
,
...
...
packages/uni-mp-vue/dist/vue.runtime.esm.js
浏览文件 @
bc0a4d43
...
...
@@ -2882,7 +2882,9 @@ const getPublicInstance = (i) => {
};
const
publicPropertiesMap
=
extend
(
Object
.
create
(
null
),
{
$
:
i
=>
i
,
$el
:
i
=>
i
.
vnode
.
el
,
// fixed by xxxxxx vue-i18n 在 dev 模式,访问了 $el,故模拟一个假的
// $el: i => i.vnode.el,
$el
:
i
=>
i
.
__$el
||
(
i
.
__$el
=
{}),
$data
:
i
=>
i
.
data
,
$props
:
i
=>
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
?
shallowReadonly
(
i
.
props
)
:
i
.
props
),
$attrs
:
i
=>
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
?
shallowReadonly
(
i
.
attrs
)
:
i
.
attrs
),
...
...
@@ -4880,6 +4882,7 @@ var plugin = {
initApp
(
app
);
// TODO 旧编译器使用了$createElement 导致告警,当切换到新编译器时,移除此类代码
app
.
config
.
globalProperties
.
$createElement
=
()
=>
{
};
app
.
config
.
globalProperties
.
$el
=
{};
const
oldMount
=
app
.
mount
;
app
.
mount
=
function
mount
(
rootContainer
)
{
const
instance
=
oldMount
.
call
(
app
,
rootContainer
);
...
...
@@ -5127,4 +5130,4 @@ function createApp(rootComponent, rootProps = null) {
}
const
createSSRApp
=
createApp
;
export
{
EffectScope
,
ReactiveEffec
t
,
c
,
callWithAsyncErrorHandling
,
callWithErrorHandling
,
computed
,
createApp
,
createSSRApp
,
createVNode$1
as
createVNode
,
createVueApp
,
customRef
,
d
,
defineComponent
,
defineEmits
,
defineExpose
,
defineProps
,
e
,
effect
,
effectScope
,
f
,
getCurrentInstance
,
getCurrentScope
,
h
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
logError
,
markRaw
,
mergeDefaults
,
mergeProps
,
n
,
nextTick
,
o
,
onActivated
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onErrorCaptured
,
onMounted
,
onRenderTracked
,
onRenderTriggered
,
onScopeDispose
,
onUnmounted
,
onUpdated
,
patch
,
provide
,
proxyRefs
,
queuePostFlushCb
,
r
,
reactive
,
readonly
,
ref
,
resolveComponent
,
resolveDirective
,
resolveFilter
,
s
,
setupDevtoolsPlugin
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
stop
,
t
,
toHandlers
,
toRaw
,
toRef
,
toRefs
,
triggerRef
,
unref
,
useAttrs
,
useSSRContext
,
useSlots
,
version
,
w
,
warn$1
as
warn
,
watch
,
watchEffect
,
watchPostEffect
,
watchSyncEffect
,
withAsyncContext
,
withCtx
,
withDefaults
,
withDirectives
,
withModifiers
,
withScopeId
};
export
{
EffectScope
,
Fragment
,
ReactiveEffect
,
Tex
t
,
c
,
callWithAsyncErrorHandling
,
callWithErrorHandling
,
computed
,
createApp
,
createSSRApp
,
createVNode$1
as
createVNode
,
createVueApp
,
customRef
,
d
,
defineComponent
,
defineEmits
,
defineExpose
,
defineProps
,
e
,
effect
,
effectScope
,
f
,
getCurrentInstance
,
getCurrentScope
,
h
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
logError
,
markRaw
,
mergeDefaults
,
mergeProps
,
n
,
nextTick
,
o
,
onActivated
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onErrorCaptured
,
onMounted
,
onRenderTracked
,
onRenderTriggered
,
onScopeDispose
,
onUnmounted
,
onUpdated
,
patch
,
provide
,
proxyRefs
,
queuePostFlushCb
,
r
,
reactive
,
readonly
,
ref
,
resolveComponent
,
resolveDirective
,
resolveFilter
,
s
,
setupDevtoolsPlugin
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
stop
,
t
,
toHandlers
,
toRaw
,
toRef
,
toRefs
,
triggerRef
,
unref
,
useAttrs
,
useSSRContext
,
useSlots
,
version
,
w
,
warn$1
as
warn
,
watch
,
watchEffect
,
watchPostEffect
,
watchSyncEffect
,
withAsyncContext
,
withCtx
,
withDefaults
,
withDirectives
,
withModifiers
,
withScopeId
};
packages/uni-mp-vue/lib/vue.runtime.esm.js
浏览文件 @
bc0a4d43
...
...
@@ -2882,7 +2882,9 @@ const getPublicInstance = (i) => {
};
const
publicPropertiesMap
=
extend
(
Object
.
create
(
null
),
{
$
:
i
=>
i
,
$el
:
i
=>
i
.
vnode
.
el
,
// fixed by xxxxxx vue-i18n 在 dev 模式,访问了 $el,故模拟一个假的
// $el: i => i.vnode.el,
$el
:
i
=>
i
.
__$el
||
(
i
.
__$el
=
{}),
$data
:
i
=>
i
.
data
,
$props
:
i
=>
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
?
shallowReadonly
(
i
.
props
)
:
i
.
props
),
$attrs
:
i
=>
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
?
shallowReadonly
(
i
.
attrs
)
:
i
.
attrs
),
...
...
@@ -4727,4 +4729,4 @@ function createVueApp(rootComponent, rootProps = null) {
function
withModifiers
()
{
}
function
createVNode$1
()
{
}
export
{
EffectScope
,
ReactiveEffec
t
,
callWithAsyncErrorHandling
,
callWithErrorHandling
,
computed
,
createVNode$1
as
createVNode
,
createVueApp
,
customRef
,
defineComponent
,
defineEmits
,
defineExpose
,
defineProps
,
effect
,
effectScope
,
getCurrentInstance
,
getCurrentScope
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
logError
,
markRaw
,
mergeDefaults
,
mergeProps
,
nextTick
,
onActivated
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onErrorCaptured
,
onMounted
,
onRenderTracked
,
onRenderTriggered
,
onScopeDispose
,
onUnmounted
,
onUpdated
,
patch
,
provide
,
proxyRefs
,
queuePostFlushCb
,
reactive
,
readonly
,
ref
,
resolveComponent
,
resolveDirective
,
resolveFilter
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
stop
,
toHandlers
,
toRaw
,
toRef
,
toRefs
,
triggerRef
,
unref
,
useAttrs
,
useSSRContext
,
useSlots
,
version
,
warn$1
as
warn
,
watch
,
watchEffect
,
watchPostEffect
,
watchSyncEffect
,
withAsyncContext
,
withCtx
,
withDefaults
,
withDirectives
,
withModifiers
,
withScopeId
};
export
{
EffectScope
,
Fragment
,
ReactiveEffect
,
Tex
t
,
callWithAsyncErrorHandling
,
callWithErrorHandling
,
computed
,
createVNode$1
as
createVNode
,
createVueApp
,
customRef
,
defineComponent
,
defineEmits
,
defineExpose
,
defineProps
,
effect
,
effectScope
,
getCurrentInstance
,
getCurrentScope
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
logError
,
markRaw
,
mergeDefaults
,
mergeProps
,
nextTick
,
onActivated
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onErrorCaptured
,
onMounted
,
onRenderTracked
,
onRenderTriggered
,
onScopeDispose
,
onUnmounted
,
onUpdated
,
patch
,
provide
,
proxyRefs
,
queuePostFlushCb
,
reactive
,
readonly
,
ref
,
resolveComponent
,
resolveDirective
,
resolveFilter
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
stop
,
toHandlers
,
toRaw
,
toRef
,
toRefs
,
triggerRef
,
unref
,
useAttrs
,
useSSRContext
,
useSlots
,
version
,
warn$1
as
warn
,
watch
,
watchEffect
,
watchPostEffect
,
watchSyncEffect
,
withAsyncContext
,
withCtx
,
withDefaults
,
withDirectives
,
withModifiers
,
withScopeId
};
packages/uni-mp-vue/src/plugin.ts
浏览文件 @
bc0a4d43
...
...
@@ -8,6 +8,7 @@ export default {
// TODO 旧编译器使用了$createElement 导致告警,当切换到新编译器时,移除此类代码
app
.
config
.
globalProperties
.
$createElement
=
()
=>
{}
app
.
config
.
globalProperties
.
$el
=
{}
const
oldMount
=
app
.
mount
app
.
mount
=
function
mount
(
rootContainer
:
any
)
{
...
...
packages/uni-mp-weixin/dist/uni.mp.esm.js
浏览文件 @
bc0a4d43
...
...
@@ -392,6 +392,16 @@ function findVmByVueId(instance, vuePid) {
}
}
}
/**
* @param properties
*/
function
fixProperties
(
properties
)
{
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
;
}
});
}
function
createObserver
(
name
)
{
return
function
observer
(
newVal
)
{
...
...
@@ -697,6 +707,8 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions, }) {
// 初始化 vue 实例
const
mpInstance
=
this
;
const
isMiniProgramPage
=
isPage
(
mpInstance
);
// 微信小程序 properties 为了解决警告问题,目前所有 type 都默认为 null,故导致部分 prop 默认值初始化不正确,故将 null 值 替换为 undefined
fixProperties
(
properties
);
this
.
$vm
=
$createComponent
({
type
:
vueOptions
,
props
:
properties
,
...
...
packages/uni-mp-weixin/src/runtime/lifetimes.ts
浏览文件 @
bc0a4d43
...
...
@@ -5,6 +5,7 @@ import {
MPComponentInstance
,
CreateComponentOptions
,
CreateLifetimesOptions
,
fixProperties
,
}
from
'
@dcloudio/uni-mp-core
'
import
{
...
...
@@ -36,6 +37,9 @@ export function initLifetimes({
const
mpInstance
=
this
const
isMiniProgramPage
=
isPage
(
mpInstance
)
// 微信小程序 properties 为了解决警告问题,目前所有 type 都默认为 null,故导致部分 prop 默认值初始化不正确,故将 null 值 替换为 undefined
fixProperties
(
properties
)
this
.
$vm
=
$createComponent
(
{
type
:
vueOptions
,
...
...
packages/uni-quickapp-webview/dist/uni.mp.esm.js
浏览文件 @
bc0a4d43
...
...
@@ -492,6 +492,16 @@ function initRefs(instance, mpInstance) {
},
});
}
/**
* @param properties
*/
function
fixProperties
(
properties
)
{
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
;
}
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
...
...
@@ -886,6 +896,13 @@ function initLifetimes$1({ mocks, isPage, initRelation, vueOptions, }) {
if
(
mpType
===
'
page
'
&&
!
mpInstance
.
route
&&
mpInstance
.
__route__
)
{
mpInstance
.
route
=
mpInstance
.
__route__
;
}
// 字节跳动小程序 properties
// 父组件在 attached 中 setData 设置了子组件的 props,在子组件的 attached 中,并不能立刻拿到
// 此时子组件的 properties 中获取到的值,除了一部分初始化就有的值,只要在模板上绑定了,动态设置的 prop 的值均会根据类型返回,不会应用 prop 自己的默认值
// 举例: easyinput 的 styles 属性,类型为 Object,`<easyinput :styles="styles"/>` 在 attached 中 styles 的值为 null
// 目前 null 值会影响 render 函数执行,临时解决方案,调整 properties 中的 null 值为 undefined,让 Vue 来补充为默认值
// 已知的其他隐患,当使用默认值时,可能组件行为不正确,比如 countdown 组件,默认值是0,导致直接就触发了 timeup 事件,这个应该是组件自身做处理?
// 难道要等父组件首次 setData 完成后,再去执行子组件的初始化?
fixProperties
(
properties
);
this
.
$vm
=
$createComponent
({
type
:
vueOptions
,
...
...
@@ -911,20 +928,6 @@ function initLifetimes$1({ mocks, isPage, initRelation, vueOptions, }) {
return
{
attached
,
detached
};
}
}
function
fixProperties
(
properties
)
{
// 字节跳动小程序 properties
// 父组件在 attached 中 setData 设置了子组件的 props,在子组件的 attached 中,并不能立刻拿到
// 此时子组件的 properties 中获取到的值,除了一部分初始化就有的值,只要在模板上绑定了,动态设置的 prop 的值均会根据类型返回,不会应用 prop 自己的默认值
// 举例: easyinput 的 styles 属性,类型为 Object,`<easyinput :styles="styles"/>` 在 attached 中 styles 的值为 null
// 目前 null 值会影响 render 函数执行,临时解决方案,调整 properties 中的 null 值为 undefined,让 Vue 来补充为默认值
// 已知的其他隐患,当使用默认值时,可能组件行为不正确,比如 countdown 组件,默认值是0,导致直接就触发了 timeup 事件,这个应该是组件自身做处理?
// 难道要等父组件首次 setData 完成后,再去执行子组件的初始化?
Object
.
keys
(
properties
).
forEach
((
name
)
=>
{
if
(
properties
[
name
]
===
null
)
{
properties
[
name
]
=
undefined
;
}
});
}
const
instances
=
Object
.
create
(
null
);
function
parse
(
componentOptions
,
{
handleLink
})
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录