diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js
index 7f6795a909747e5b32e36347be809ec98f7df86a..b4e280182041ddfe2778ef0ba7dfe73e91412e95 100644
--- a/packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js
@@ -178,6 +178,10 @@ describe('codegen', () => {
'
',
`with(this){return _c('div',[_t("one",null,{"_i":1})],2)}`
)
+ assertCodegen(
+ '
',
+ `with(this){return _c('div',[_t(_$s(1,'name',one),null,{"_i":1})],2)}`
+ )
})
it('generate slot fallback content', () => {
diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
index 25188522636ae47f71722ae39f04972c1d5e47fa..b15a153c0a65e91fd5a8914011e1720cd219e281 100644
--- a/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
@@ -178,6 +178,10 @@ describe('codegen', () => {
'
',
`with(this){return _c('div',{attrs:{"_i":0}},[_t("one",null,{"_i":1})],2)}`
)
+ assertCodegen(
+ '
',
+ `with(this){return _c('div',{attrs:{"_i":0}},[_t(_$g(1,'name'),null,{"_i":1})],2)}`
+ )
})
it('generate slot fallback content', () => {
diff --git a/packages/uni-template-compiler/lib/app/parser/base-parser.js b/packages/uni-template-compiler/lib/app/parser/base-parser.js
index 5094693fb97b130d2b03f2c8bad1cf46583aaccf..1bca0b2347e1be3a4d63bafed3db074c9fa50183 100644
--- a/packages/uni-template-compiler/lib/app/parser/base-parser.js
+++ b/packages/uni-template-compiler/lib/app/parser/base-parser.js
@@ -2,6 +2,7 @@ const {
ID,
C_IS,
C_REF,
+ C_NAME,
V_IF,
V_FOR,
V_ELSE_IF,
@@ -16,6 +17,12 @@ function parseRef (el, genVar) {
}
}
+function parseSlotName (el, genVar) {
+ if (el.slotName && isVar(el.slotName)) {
+ el.slotName = genVar(C_NAME, el.slotName)
+ }
+}
+
function parseIs (el, genVar) {
if (!el.component) {
return
@@ -106,6 +113,7 @@ function parseText (el, parent, state) {
module.exports = {
parseIs,
parseRef,
+ parseSlotName,
parseIf,
parseFor,
parseText,
diff --git a/packages/uni-template-compiler/lib/app/service.js b/packages/uni-template-compiler/lib/app/service.js
index 72d36fb7309f55eadf4aa8721ec2af6dec3f0328..da63bc1c568651b4a895541651cabaa961a1f907 100644
--- a/packages/uni-template-compiler/lib/app/service.js
+++ b/packages/uni-template-compiler/lib/app/service.js
@@ -18,6 +18,7 @@ const {
const {
parseIs,
parseRef,
+ parseSlotName,
parseIf,
parseFor,
parseText,
@@ -137,6 +138,7 @@ function transformNode (el, parent, state, isScopedSlot) {
parseIs(el, genVar)
parseRef(el, genVar)
+ parseSlotName(el, genVar)
parseFor(el, createGenVar, isScopedSlot, checkAutoFill(el))
parseKey(el, isScopedSlot)
diff --git a/packages/uni-template-compiler/lib/app/util.js b/packages/uni-template-compiler/lib/app/util.js
index 3de296a6118b97f1890615b8030268b653bc992f..c259090eeeceddfbbd1fbdf9754cb0d1ba8dcfef 100644
--- a/packages/uni-template-compiler/lib/app/util.js
+++ b/packages/uni-template-compiler/lib/app/util.js
@@ -15,6 +15,7 @@ const GET_CHANGE_DATA = '_$gc' // wxs
const C_IS = 'is'
const C_SLOT_TARGET = 'st'
const C_REF = 'ref'
+const C_NAME = 'name'
const V_FOR = 'f'
const V_IF = 'i'
@@ -268,6 +269,7 @@ function addHandler (el, name, value, important) {
module.exports = {
C_IS,
C_REF,
+ C_NAME,
V_FOR,
V_IF,
V_ELSE_IF,
diff --git a/packages/uni-template-compiler/lib/app/view.js b/packages/uni-template-compiler/lib/app/view.js
index b0ab64641b00d6dbb327032fc214759b07ae7c0b..8a568e4c541c2c96a4fc31bfd8631a512400c0a8 100644
--- a/packages/uni-template-compiler/lib/app/view.js
+++ b/packages/uni-template-compiler/lib/app/view.js
@@ -13,6 +13,7 @@ const {
const {
parseIs,
parseRef,
+ parseSlotName,
parseIf,
parseFor,
parseText,
@@ -130,6 +131,7 @@ function transformNode (el, parent, state, isScopedSlot) {
parseIs(el, genVar)
parseRef(el, genVar)
+ parseSlotName(el, genVar)
if (parseFor(el, createGenVar, isScopedSlot)) {
if (el.alias[0] === '{') { //
el.alias = '$item'