提交 e1801408 编写于 作者: Q qiang

Merge branch 'dev' into alpha

# Conflicts:
#	packages/uni-mp-kuaishou/dist/index.js
...@@ -1400,9 +1400,6 @@ var serviceContext = (function () { ...@@ -1400,9 +1400,6 @@ var serviceContext = (function () {
t(key, values) { t(key, values) {
return t(key, values); return t(key, values);
}, },
getLocale() {
return i18n.getLocale();
},
setLocale(newLocale) { setLocale(newLocale) {
return i18n.setLocale(newLocale); return i18n.setLocale(newLocale);
}, },
...@@ -20964,6 +20961,9 @@ var serviceContext = (function () { ...@@ -20964,6 +20961,9 @@ var serviceContext = (function () {
} }
const evalJSCode = const evalJSCode =
`typeof UniViewJSBridge !== 'undefined' && UniViewJSBridge.subscribeHandler("${eventType}",${args},__PAGE_ID__)`; `typeof UniViewJSBridge !== 'undefined' && UniViewJSBridge.subscribeHandler("${eventType}",${args},__PAGE_ID__)`;
if (process.env.NODE_ENV !== 'production') {
console.log(`UNIAPP[publishHandler]:[${+new Date()}]`, 'length', evalJSCode.length);
}
pageIds.forEach(id => { pageIds.forEach(id => {
const webview = plus.webview.getWebviewById(String(id)); const webview = plus.webview.getWebviewById(String(id));
webview && webview.evalJS(evalJSCode.replace('__PAGE_ID__', id)); webview && webview.evalJS(evalJSCode.replace('__PAGE_ID__', id));
......
...@@ -27,7 +27,7 @@ module.exports = { ...@@ -27,7 +27,7 @@ module.exports = {
subPackages: true subPackages: true
}, },
copyWebpackOptions (platformOptions, vueOptions) { copyWebpackOptions (platformOptions, vueOptions) {
const copyOptions = [] const copyOptions = ['androidPrivacy.json']
const componentsCopyOption = getComponentsCopyOption() const componentsCopyOption = getComponentsCopyOption()
if (componentsCopyOption) { if (componentsCopyOption) {
copyOptions.push(componentsCopyOption) copyOptions.push(componentsCopyOption)
......
import { isPlainObject, isArray, extend, hyphenate, isObject, hasOwn, toNumber, capitalize, isFunction, NOOP, EMPTY_OBJ, camelize } from '@vue/shared'; import { isPlainObject, isArray, extend, hyphenate, isObject, hasOwn, toNumber, capitalize, isFunction, NOOP, EMPTY_OBJ, camelize } from '@vue/shared';
import { onUnmounted } from 'vue';
const encode = encodeURIComponent; const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) { function stringifyQuery(obj, encodeStr = encode) {
...@@ -391,6 +392,9 @@ function initBaseInstance(instance, options) { ...@@ -391,6 +392,9 @@ function initBaseInstance(instance, options) {
} }
function initComponentInstance(instance, options) { function initComponentInstance(instance, options) {
initBaseInstance(instance, options); initBaseInstance(instance, options);
{
initScopedSlotsParams(instance);
}
const ctx = instance.ctx; const ctx = instance.ctx;
MP_METHODS.forEach((method) => { MP_METHODS.forEach((method) => {
ctx[method] = function (...args) { ctx[method] = function (...args) {
...@@ -440,6 +444,53 @@ function callHook(name, args) { ...@@ -440,6 +444,53 @@ function callHook(name, args) {
} }
const hooks = this.$[name]; const hooks = this.$[name];
return hooks && invokeArrayFns(hooks, args); return hooks && invokeArrayFns(hooks, args);
}
const center = {};
const parents = {};
function initScopedSlotsParams(instance) {
const ctx = instance.ctx;
ctx.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
return has;
};
ctx.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object;
}
else {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
};
ctx.$setScopedSlotsParams = function (name, value) {
const vueIds = instance.attrs.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
onUnmounted(function () {
const propsData = instance.attrs;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}, instance);
} }
const PAGE_HOOKS = [ const PAGE_HOOKS = [
......
import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared'; import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared';
import { onUnmounted } from 'vue';
const encode = encodeURIComponent; const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) { function stringifyQuery(obj, encodeStr = encode) {
...@@ -419,6 +420,9 @@ function initBaseInstance(instance, options) { ...@@ -419,6 +420,9 @@ function initBaseInstance(instance, options) {
} }
function initComponentInstance(instance, options) { function initComponentInstance(instance, options) {
initBaseInstance(instance, options); initBaseInstance(instance, options);
{
initScopedSlotsParams(instance);
}
const ctx = instance.ctx; const ctx = instance.ctx;
MP_METHODS.forEach((method) => { MP_METHODS.forEach((method) => {
ctx[method] = function (...args) { ctx[method] = function (...args) {
...@@ -465,6 +469,53 @@ function callHook(name, args) { ...@@ -465,6 +469,53 @@ function callHook(name, args) {
} }
const hooks = this.$[name]; const hooks = this.$[name];
return hooks && invokeArrayFns(hooks, args); return hooks && invokeArrayFns(hooks, args);
}
const center = {};
const parents = {};
function initScopedSlotsParams(instance) {
const ctx = instance.ctx;
ctx.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
return has;
};
ctx.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object;
}
else {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
};
ctx.$setScopedSlotsParams = function (name, value) {
const vueIds = instance.attrs.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
onUnmounted(function () {
const propsData = instance.attrs;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}, instance);
} }
const PAGE_HOOKS = [ const PAGE_HOOKS = [
......
...@@ -1845,13 +1845,12 @@ function fixSetDataEnd (mpInstance) { ...@@ -1845,13 +1845,12 @@ function fixSetDataEnd (mpInstance) {
} }
} }
const SDKVersion = ks.getSystemInfoSync().SDKVersion;
function parseComponent$1 (vueComponentOptions) { function parseComponent$1 (vueComponentOptions) {
const componentOptions = parseComponent(vueComponentOptions); const componentOptions = parseComponent(vueComponentOptions);
const oldAttached = componentOptions.lifetimes.attached; const oldAttached = componentOptions.lifetimes.attached;
componentOptions.lifetimes.attached = function attached () { componentOptions.lifetimes.attached = function attached () {
if (isPage.call(this) && parseFloat(SDKVersion) <= 1.13) { // 暂不区分版本
if (isPage.call(this)) {
// 解决快手小程序页面 attached 生命周期 setData 导致数据同步异常的问题 // 解决快手小程序页面 attached 生命周期 setData 导致数据同步异常的问题
fixSetDataStart(this); fixSetDataStart(this);
setTimeout(() => { setTimeout(() => {
......
此差异已折叠。
此差异已折叠。
import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared'; import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared';
import { onUnmounted } from 'vue';
const encode = encodeURIComponent; const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) { function stringifyQuery(obj, encodeStr = encode) {
...@@ -419,6 +420,9 @@ function initBaseInstance(instance, options) { ...@@ -419,6 +420,9 @@ function initBaseInstance(instance, options) {
} }
function initComponentInstance(instance, options) { function initComponentInstance(instance, options) {
initBaseInstance(instance, options); initBaseInstance(instance, options);
{
initScopedSlotsParams(instance);
}
const ctx = instance.ctx; const ctx = instance.ctx;
MP_METHODS.forEach((method) => { MP_METHODS.forEach((method) => {
ctx[method] = function (...args) { ctx[method] = function (...args) {
...@@ -465,6 +469,53 @@ function callHook(name, args) { ...@@ -465,6 +469,53 @@ function callHook(name, args) {
} }
const hooks = this.$[name]; const hooks = this.$[name];
return hooks && invokeArrayFns(hooks, args); return hooks && invokeArrayFns(hooks, args);
}
const center = {};
const parents = {};
function initScopedSlotsParams(instance) {
const ctx = instance.ctx;
ctx.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
return has;
};
ctx.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object;
}
else {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
};
ctx.$setScopedSlotsParams = function (name, value) {
const vueIds = instance.attrs.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
onUnmounted(function () {
const propsData = instance.attrs;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}, instance);
} }
const PAGE_HOOKS = [ const PAGE_HOOKS = [
......
import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared'; import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared';
import { onUnmounted } from 'vue';
const encode = encodeURIComponent; const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) { function stringifyQuery(obj, encodeStr = encode) {
...@@ -419,6 +420,9 @@ function initBaseInstance(instance, options) { ...@@ -419,6 +420,9 @@ function initBaseInstance(instance, options) {
} }
function initComponentInstance(instance, options) { function initComponentInstance(instance, options) {
initBaseInstance(instance, options); initBaseInstance(instance, options);
{
initScopedSlotsParams(instance);
}
const ctx = instance.ctx; const ctx = instance.ctx;
MP_METHODS.forEach((method) => { MP_METHODS.forEach((method) => {
ctx[method] = function (...args) { ctx[method] = function (...args) {
...@@ -465,6 +469,53 @@ function callHook(name, args) { ...@@ -465,6 +469,53 @@ function callHook(name, args) {
} }
const hooks = this.$[name]; const hooks = this.$[name];
return hooks && invokeArrayFns(hooks, args); return hooks && invokeArrayFns(hooks, args);
}
const center = {};
const parents = {};
function initScopedSlotsParams(instance) {
const ctx = instance.ctx;
ctx.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
return has;
};
ctx.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object;
}
else {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
};
ctx.$setScopedSlotsParams = function (name, value) {
const vueIds = instance.attrs.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
onUnmounted(function () {
const propsData = instance.attrs;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}, instance);
} }
const PAGE_HOOKS = [ const PAGE_HOOKS = [
......
import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared'; import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared';
import { onUnmounted } from 'vue';
const encode = encodeURIComponent; const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) { function stringifyQuery(obj, encodeStr = encode) {
...@@ -365,6 +366,9 @@ function initBaseInstance(instance, options) { ...@@ -365,6 +366,9 @@ function initBaseInstance(instance, options) {
} }
function initComponentInstance(instance, options) { function initComponentInstance(instance, options) {
initBaseInstance(instance, options); initBaseInstance(instance, options);
{
initScopedSlotsParams(instance);
}
const ctx = instance.ctx; const ctx = instance.ctx;
MP_METHODS.forEach((method) => { MP_METHODS.forEach((method) => {
ctx[method] = function (...args) { ctx[method] = function (...args) {
...@@ -411,6 +415,53 @@ function callHook(name, args) { ...@@ -411,6 +415,53 @@ function callHook(name, args) {
} }
const hooks = this.$[name]; const hooks = this.$[name];
return hooks && invokeArrayFns(hooks, args); return hooks && invokeArrayFns(hooks, args);
}
const center = {};
const parents = {};
function initScopedSlotsParams(instance) {
const ctx = instance.ctx;
ctx.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
return has;
};
ctx.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object;
}
else {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
};
ctx.$setScopedSlotsParams = function (name, value) {
const vueIds = instance.attrs.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
onUnmounted(function () {
const propsData = instance.attrs;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}, instance);
} }
const PAGE_HOOKS = [ const PAGE_HOOKS = [
......
...@@ -28,7 +28,8 @@ module.exports = { ...@@ -28,7 +28,8 @@ module.exports = {
'sitemap.json', 'sitemap.json',
'ext.json', 'ext.json',
'custom-tab-bar', 'custom-tab-bar',
'plugin.json' 'plugin.json',
'functional-pages'
] ]
const workers = platformOptions.workers const workers = platformOptions.workers
workers && copyOptions.push(workers) workers && copyOptions.push(workers)
......
...@@ -97,6 +97,14 @@ describe('mp:compiler-mp-weixin', () => { ...@@ -97,6 +97,14 @@ describe('mp:compiler-mp-weixin', () => {
scopedSlotsCompiler: 'auto' scopedSlotsCompiler: 'auto'
} }
) )
assertCodegen(
'<my-component><template v-slot="{item}"><view @click="getValue(item)">{{item}}</view><template></my-component>',
'<my-component generic:scoped-slots-default="test-my-component-default" data-vue-generic="scoped" vue-id="551070e6-1" bind:__l="__l" vue-slots="{{[\'default\']}}"></my-component>',
'with(this){}',
{
scopedSlotsCompiler: 'auto'
}
)
assertCodegen( assertCodegen(
'<my-component><template v-slot="{item}">{{getValue(item)}}<template></my-component>', '<my-component><template v-slot="{item}">{{getValue(item)}}<template></my-component>',
'<my-component scoped-slots-compiler="augmented" vue-id="551070e6-1" bind:__l="__l" vue-slots="{{[\'default\']}}"><block><block wx:if="{{$root.m0}}">{{$root.m1}}</block></block></my-component>', '<my-component scoped-slots-compiler="augmented" vue-id="551070e6-1" bind:__l="__l" vue-slots="{{[\'default\']}}"><block><block wx:if="{{$root.m0}}">{{$root.m1}}</block></block></my-component>',
......
...@@ -62,7 +62,8 @@ const tags = { ...@@ -62,7 +62,8 @@ const tags = {
'cashier', 'cashier',
'ix-grid', 'ix-grid',
'ix-native-grid', 'ix-native-grid',
'ix-native-list' 'ix-native-list',
'mkt'
] ]
} }
......
...@@ -2,17 +2,27 @@ const t = require('@babel/types') ...@@ -2,17 +2,27 @@ const t = require('@babel/types')
const { const {
METHOD_BUILT_IN, METHOD_BUILT_IN,
METHOD_CREATE_EMPTY_VNODE METHOD_CREATE_EMPTY_VNODE,
METHOD_CREATE_ELEMENT
} = require('../../constants') } = require('../../constants')
function needSlotMode (path, ids) { function needSlotMode (path, ids) {
let need let need
path.traverse({ path.traverse({
noScope: false, noScope: false,
Property (path) {
// 跳过事件
if (path.node.key.name === 'on') {
const parentPath = path.parentPath.parentPath
if (t.isCallExpression(parentPath) && parentPath.node.callee.name === METHOD_CREATE_ELEMENT) {
path.skip()
}
}
},
Identifier (path) { Identifier (path) {
const name = path.node.name const name = path.node.name
if (path.key !== 'key' && (path.key !== 'property' || path.parent.computed)) { if (path.key !== 'key' && (path.key !== 'property' || path.parent.computed)) {
// 使用方法或作用域外数据 // 使用作用域内方法或作用域外数据
if (name in ids) { if (name in ids) {
need = path.key === 'callee' ? true : need need = path.key === 'callee' ? true : need
} else if (!path.scope.hasBinding(name) && !METHOD_BUILT_IN.includes(name)) { } else if (!path.scope.hasBinding(name) && !METHOD_BUILT_IN.includes(name)) {
......
...@@ -208,7 +208,16 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) { ...@@ -208,7 +208,16 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
const array = [{ const array = [{
from: path.resolve(process.env.UNI_INPUT_DIR, 'static'), from: path.resolve(process.env.UNI_INPUT_DIR, 'static'),
to: 'static' to: 'static'
}] }]
const androidPrivacyPath = path.resolve(process.env.UNI_INPUT_DIR, 'androidPrivacy.json')
if (fs.existsSync(androidPrivacyPath)) {
array.push({
from: androidPrivacyPath,
to: 'androidPrivacy.json'
})
}
const hybridHtmlPath = path.resolve(process.env.UNI_INPUT_DIR, 'hybrid/html') const hybridHtmlPath = path.resolve(process.env.UNI_INPUT_DIR, 'hybrid/html')
if (fs.existsSync(hybridHtmlPath)) { if (fs.existsSync(hybridHtmlPath)) {
array.push({ array.push({
...@@ -216,6 +225,7 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) { ...@@ -216,6 +225,7 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
to: 'hybrid/html' to: 'hybrid/html'
}) })
} }
if (process.env.UNI_USING_NVUE_COMPILER) { if (process.env.UNI_USING_NVUE_COMPILER) {
array.push({ array.push({
from: path.resolve(getTemplatePath(), 'common'), from: path.resolve(getTemplatePath(), 'common'),
......
...@@ -283,10 +283,6 @@ process.env.SCOPED_SLOTS_COMPILER = modes.includes(scopedSlotsCompiler) ? scoped ...@@ -283,10 +283,6 @@ process.env.SCOPED_SLOTS_COMPILER = modes.includes(scopedSlotsCompiler) ? scoped
if (process.env.UNI_PLATFORM === 'mp-kuaishou' && process.env.SCOPED_SLOTS_COMPILER !== modes[0]) { if (process.env.UNI_PLATFORM === 'mp-kuaishou' && process.env.SCOPED_SLOTS_COMPILER !== modes[0]) {
process.env.SCOPED_SLOTS_COMPILER = modes[2] process.env.SCOPED_SLOTS_COMPILER = modes[2]
} }
// Vue3 暂时固定为 legacy 模式
if (process.env.UNI_USING_VUE3) {
process.env.SCOPED_SLOTS_COMPILER = modes[0]
}
if ( if (
process.env.UNI_USING_COMPONENTS || process.env.UNI_USING_COMPONENTS ||
......
...@@ -172,7 +172,7 @@ module.exports = { ...@@ -172,7 +172,7 @@ module.exports = {
if (process.env.UNI_MP_PLUGIN) { if (process.env.UNI_MP_PLUGIN) {
// 小程序插件入口使用 // 小程序插件入口使用
// packages\webpack-uni-mp-loader\lib\plugin\index-new.js -> addMPPluginRequire // packages\webpack-uni-mp-loader\lib\plugin\index-new.js -> addMPPluginRequire
beforeCode += `wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace('-', '_')}__ = __webpack_require__;` beforeCode += `wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace(/-/g, '_')}__ = __webpack_require__;`
const UNI_MP_PLUGIN_MAIN = process.env.UNI_MP_PLUGIN_MAIN const UNI_MP_PLUGIN_MAIN = process.env.UNI_MP_PLUGIN_MAIN
if (UNI_MP_PLUGIN_MAIN) { if (UNI_MP_PLUGIN_MAIN) {
...@@ -304,4 +304,4 @@ module.exports = { ...@@ -304,4 +304,4 @@ module.exports = {
webpackConfig.plugins.delete('preload') webpackConfig.plugins.delete('preload')
webpackConfig.plugins.delete('prefetch') webpackConfig.plugins.delete('prefetch')
} }
} }
...@@ -73,14 +73,14 @@ function addMPPluginRequire (compilation) { ...@@ -73,14 +73,14 @@ function addMPPluginRequire (compilation) {
if (name === process.env.UNI_MP_PLUGIN_MAIN) { if (name === process.env.UNI_MP_PLUGIN_MAIN) {
const modules = compilation.modules const modules = compilation.modules
const mainFilePath = path.resolve(process.env.UNI_INPUT_DIR, process.env.UNI_MP_PLUGIN_MAIN).replace(/\\/g, '/') const mainFilePath = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, process.env.UNI_MP_PLUGIN_MAIN))
const uniModuleId = modules.find(module => module.resource && normalizePath(module.resource) === mainFilePath).id const uniModuleId = modules.find(module => module.resource && normalizePath(module.resource) === mainFilePath).id
const newlineIndex = compilation.assets[name].source().lastIndexOf('\n') const newlineIndex = compilation.assets[name].source().lastIndexOf('\n')
const source = compilation.assets[name].source().substring(0, newlineIndex) + const source = compilation.assets[name].source().substring(0, newlineIndex) +
`\nmodule.exports = wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace('-', '_')}__(${uniModuleId});\n` + `\nmodule.exports = wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace(/-/g, '_')}__('${uniModuleId}');\n` +
compilation.assets[name].source().substring(newlineIndex + 1) compilation.assets[name].source().substring(newlineIndex + 1)
compilation.assets[name] = { compilation.assets[name] = {
......
...@@ -7,13 +7,12 @@ import { ...@@ -7,13 +7,12 @@ import {
fixSetDataEnd fixSetDataEnd
} from '../../../mp-weixin/runtime/wrapper/fix-set-data' } from '../../../mp-weixin/runtime/wrapper/fix-set-data'
const SDKVersion = __GLOBAL__.getSystemInfoSync().SDKVersion
export default function parseComponent (vueComponentOptions) { export default function parseComponent (vueComponentOptions) {
const componentOptions = parseBaseComponent(vueComponentOptions) const componentOptions = parseBaseComponent(vueComponentOptions)
const oldAttached = componentOptions.lifetimes.attached const oldAttached = componentOptions.lifetimes.attached
componentOptions.lifetimes.attached = function attached () { componentOptions.lifetimes.attached = function attached () {
if (isPage.call(this) && parseFloat(SDKVersion) <= 1.13) { // 暂不区分版本
if (isPage.call(this)) {
// 解决快手小程序页面 attached 生命周期 setData 导致数据同步异常的问题 // 解决快手小程序页面 attached 生命周期 setData 导致数据同步异常的问题
fixSetDataStart(this) fixSetDataStart(this)
setTimeout(() => { setTimeout(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册