提交 f1521aaa 编写于 作者: fxy060608's avatar fxy060608

fix(mp-dd): component lifecycle

上级 f456e034
...@@ -1667,8 +1667,7 @@ const customize = cached((str) => { ...@@ -1667,8 +1667,7 @@ const customize = cached((str) => {
return camelize(str.replace(customizeRE, '-')) return camelize(str.replace(customizeRE, '-'))
}); });
// 钉钉小程序是 component2 模式 const isComponent2 = my.canIUse('component2');
const isComponent2 = my.dd || my.canIUse('component2');
const mocks = ['$id']; const mocks = ['$id'];
...@@ -2023,8 +2022,14 @@ function parseComponent (vueComponentOptions) { ...@@ -2023,8 +2022,14 @@ function parseComponent (vueComponentOptions) {
mixins: initBehaviors(vueOptions, initBehavior), mixins: initBehaviors(vueOptions, initBehavior),
data: initData(vueOptions, Vue.prototype), data: initData(vueOptions, Vue.prototype),
props, props,
didMount () { didMount () {
initVm.call(this, VueComponent); if (my.dd) { // 钉钉小程序底层基础库有 bug,组件嵌套使用时,在 didMount 中无法及时调用 props 中的方法
setTimeout(() => {
initVm.call(this, VueComponent);
}, 4);
} else {
initVm.call(this, VueComponent);
}
initSpecialMethods(this); initSpecialMethods(this);
......
...@@ -1214,6 +1214,11 @@ function parseBaseApp (vm, { ...@@ -1214,6 +1214,11 @@ function parseBaseApp (vm, {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前 if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return return
} }
{
if (!wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上');
}
}
this.$vm = vm; this.$vm = vm;
...@@ -1339,6 +1344,13 @@ function parseBaseComponent (vueComponentOptions, { ...@@ -1339,6 +1344,13 @@ function parseBaseComponent (vueComponentOptions, {
addGlobalClass: true addGlobalClass: true
}; };
{
// 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) {
Object.assign(options, vueOptions['mp-weixin']['options']);
}
}
const componentOptions = { const componentOptions = {
options, options,
data: initData(vueOptions, Vue.prototype), data: initData(vueOptions, Vue.prototype),
......
...@@ -1281,7 +1281,7 @@ function parseBaseComponent (vueComponentOptions, { ...@@ -1281,7 +1281,7 @@ function parseBaseComponent (vueComponentOptions, {
}; };
{ {
// 微信multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项 // 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) { if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) {
Object.assign(options, vueOptions['mp-weixin']['options']); Object.assign(options, vueOptions['mp-weixin']['options']);
} }
......
...@@ -91,8 +91,14 @@ export default function parseComponent (vueComponentOptions) { ...@@ -91,8 +91,14 @@ export default function parseComponent (vueComponentOptions) {
mixins: initBehaviors(vueOptions, initBehavior), mixins: initBehaviors(vueOptions, initBehavior),
data: initData(vueOptions, Vue.prototype), data: initData(vueOptions, Vue.prototype),
props, props,
didMount () { didMount () {
initVm.call(this, VueComponent) if (my.dd) { // 钉钉小程序底层基础库有 bug,组件嵌套使用时,在 didMount 中无法及时调用 props 中的方法
setTimeout(() => {
initVm.call(this, VueComponent)
}, 4)
} else {
initVm.call(this, VueComponent)
}
initSpecialMethods(this) initSpecialMethods(this)
......
...@@ -16,8 +16,7 @@ const customize = cached((str) => { ...@@ -16,8 +16,7 @@ const customize = cached((str) => {
return camelize(str.replace(customizeRE, '-')) return camelize(str.replace(customizeRE, '-'))
}) })
// 钉钉小程序是 component2 模式 export const isComponent2 = my.canIUse('component2')
export const isComponent2 = my.dd || my.canIUse('component2')
export const mocks = ['$id'] export const mocks = ['$id']
......
...@@ -52,7 +52,7 @@ export default function parseBaseApp (vm, { ...@@ -52,7 +52,7 @@ export default function parseBaseApp (vm, {
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前 if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return return
} }
if (__PLATFORM__ === 'mp-weixin') { if (__PLATFORM__ === 'mp-weixin' || __PLATFORM__ === 'mp-qq') {
if (!wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断 if (!wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上') console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上')
} }
......
...@@ -26,8 +26,8 @@ export default function parseBaseComponent (vueComponentOptions, { ...@@ -26,8 +26,8 @@ export default function parseBaseComponent (vueComponentOptions, {
addGlobalClass: true addGlobalClass: true
} }
if (__PLATFORM__ === 'mp-weixin') { if (__PLATFORM__ === 'mp-weixin' || __PLATFORM__ === 'mp-qq') {
// 微信multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项 // 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) { if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) {
Object.assign(options, vueOptions['mp-weixin']['options']) Object.assign(options, vueOptions['mp-weixin']['options'])
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册