diff --git a/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js b/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js index 355f816b5e7090a440d0ab1e5552bfff53f1c1f7..26ed0cf0f934d5e18ac1db01a424ad9d3f754417 100644 --- a/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js @@ -115,7 +115,7 @@ describe('mp:compiler-mp-alipay', () => { assertCodegen( '', '', - 'with(this){if($mp.component.props.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",{"item":item})}}', + 'with(this){if($scope.props.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",{"item":item})}}', { scopedSlotsCompiler: 'auto' } @@ -123,7 +123,7 @@ describe('mp:compiler-mp-alipay', () => { assertCodegen( '', '', - 'with(this){if($mp.component.props.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",object)}}', + 'with(this){if($scope.props.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",object)}}', { scopedSlotsCompiler: 'auto' } diff --git a/packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js b/packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js index d2c9c7cd0de7677f7e4c84d4760655307d3300b9..398051d318e816d4b51d32238ae25f255540edd6 100644 --- a/packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js @@ -93,7 +93,7 @@ describe('mp:compiler-mp-baidu', () => { assertCodegen( '', '', - 'with(this){if($mp.component.data.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",{"item":item})}}', + 'with(this){if($scope.data.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",{"item":item})}}', { scopedSlotsCompiler: 'auto' } @@ -101,7 +101,7 @@ describe('mp:compiler-mp-baidu', () => { assertCodegen( '', '', - 'with(this){if($mp.component.data.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",object)}}', + 'with(this){if($scope.data.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",object)}}', { scopedSlotsCompiler: 'auto' } diff --git a/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js b/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js index c8e413faeebcbf62e1c40962cafc05e0fdc6aef5..f6ee2963b7191cfc6d1af82cc0f505aa00207572 100644 --- a/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js @@ -110,7 +110,7 @@ describe('mp:compiler-mp-weixin', () => { assertCodegen( '', '', - 'with(this){if($mp.component.data.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",{"item":item})}}', + 'with(this){if($scope.data.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",{"item":item})}}', { scopedSlotsCompiler: 'auto' } @@ -118,7 +118,7 @@ describe('mp:compiler-mp-weixin', () => { assertCodegen( '', '', - 'with(this){var m0=getValue(item);$mp.data=Object.assign({},{$root:{m0:m0}});if($mp.component.data.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",{"item":$root.m0})}}', + 'with(this){var m0=getValue(item);$mp.data=Object.assign({},{$root:{m0:m0}});if($scope.data.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",{"item":$root.m0})}}', { scopedSlotsCompiler: 'auto' } @@ -126,7 +126,7 @@ describe('mp:compiler-mp-weixin', () => { assertCodegen( '', '', - 'with(this){if($mp.component.data.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",object)}}', + 'with(this){if($scope.data.scopedSlotsCompiler==="augmented"){const $root=$mp.data.$root;$setScopedSlotsParams("default",object)}}', { scopedSlotsCompiler: 'auto' } diff --git a/packages/uni-template-compiler/lib/script/traverse/index.js b/packages/uni-template-compiler/lib/script/traverse/index.js index 506c880b5ca0bda0f27851a855e7065a481ae361..6cd2f5b0f30c6a5c37394eb9587f516676a6c123 100644 --- a/packages/uni-template-compiler/lib/script/traverse/index.js +++ b/packages/uni-template-compiler/lib/script/traverse/index.js @@ -117,7 +117,7 @@ module.exports = function traverse (ast, state) { if (state.options.scopedSlotsCompiler === 'auto') { const node = t.ifStatement( t.binaryExpression('===', - t.memberExpression(t.memberExpression(t.memberExpression(t.identifier('$mp'), t.identifier('component')), t.identifier(state.options.platform.name === 'mp-alipay' ? 'props' : 'data')), t.identifier('scopedSlotsCompiler')), t.stringLiteral('augmented') + t.memberExpression(t.memberExpression(t.identifier('$scope'), t.identifier(state.options.platform.name === 'mp-alipay' ? 'props' : 'data')), t.identifier('scopedSlotsCompiler')), t.stringLiteral('augmented') ), t.blockStatement([ t.variableDeclaration('const', [t.variableDeclarator(t.identifier('$root'),