diff --git a/packages/mars-build/src/compiler/file/compileModules.js b/packages/mars-build/src/compiler/file/compileModules.js index b9f84e56..46d72c50 100644 --- a/packages/mars-build/src/compiler/file/compileModules.js +++ b/packages/mars-build/src/compiler/file/compileModules.js @@ -141,14 +141,16 @@ async function compileUIModules(uiModules, destPath) { const coreEntry = require.resolve(realName + '/mars-core', { paths: [process.cwd()] }); - const entry = coreEntry.replace('mars-core/index.js', ''); + // 获取当前操作系统的路径分隔符,否则windwos环境替换不成功 + const entry = coreEntry.replace(`mars-core${path.sep}index.js`, ''); const dest = path.resolve(destPath, modPath); const coreDestPath = path.resolve(destPath, 'mars-core'); const uiCoreDestPath = path.resolve(dest, 'mars-core'); + // 修改windows环境反斜杠为斜杠 const coreRelativePath = path.relative( uiCoreDestPath, coreDestPath - ); + ).replace(/\\/g, '/'); if (fs.existsSync(uiCoreDestPath + '/index.js')) { return; } diff --git a/packages/mars-build/src/gulp-mars-h5.js b/packages/mars-build/src/gulp-mars-h5.js index ce7fef20..77f64f6d 100644 --- a/packages/mars-build/src/gulp-mars-h5.js +++ b/packages/mars-build/src/gulp-mars-h5.js @@ -260,7 +260,8 @@ async function compile(file, opt) { } // 持续集成 main.js pageTitleMap - let filePathKey = rPath.replace(/\.vue$/, ''); + // windwos环境下的反斜杠替换为斜杠,否则输出的pageTitleMap为空 + let filePathKey = rPath.replace(/\.vue$/, '').replace(/\\/g, '/'); const isComp = config.component; if (!isComp) { pagesInfo[filePathKey] = config; diff --git a/packages/mars-core/src/base/createComponent.js b/packages/mars-core/src/base/createComponent.js index 615bb4e2..8874076d 100644 --- a/packages/mars-core/src/base/createComponent.js +++ b/packages/mars-core/src/base/createComponent.js @@ -11,7 +11,8 @@ import config from '../config'; export function makeVueCompCreator(getCompMixin) { return function vueCompCreator(options) { - options.mixins = [getCompMixin(options)]; + // 如果 options(vue组件的代码)中已有 mixins,则同时保留 options中的 mixins + options.mixins = [getCompMixin(options), ...options.mixins || []]; return options; }; } diff --git a/packages/mars-core/src/base/createPage.js b/packages/mars-core/src/base/createPage.js index c48f941e..52b2d739 100644 --- a/packages/mars-core/src/base/createPage.js +++ b/packages/mars-core/src/base/createPage.js @@ -75,7 +75,8 @@ export function makeCreatePage(pageMixin, {handleProxy, handleModel}, setData, c $api }) { return function (options) { - options.mixins = [pageMixin]; + // 如果 options(vue页面的代码)中已有 mixins,则同时保留 options中的 mixins + options.mixins = [pageMixin, ...options.mixins || []]; let initData = typeof options.data === 'function' ? options.data.call({ $api