智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LightingSystemApp-serial/.svn/pristine/d2/d26b978f58e01e28dae5255e717...

44 lines
1.3 KiB

3 years ago
const t = require('@babel/types')
const {
CLASS_REF,
CLASS_REF_IN_FOR
} = require('../../../constants')
module.exports = function processRef (paths, path, state) {
const refPath = paths.ref
if (refPath) {
if (state.options.platform.name === 'mp-alipay') {
return [
t.objectProperty( // data-ref="" ,data-ref-in-for=""
t.stringLiteral('ref'),
t.stringLiteral('__r')
),
t.objectProperty( // data-ref="" ,data-ref-in-for=""
t.stringLiteral(state.inFor ? state.options.platform.refInFor : state.options.platform.ref),
refPath.node.value
)
]
}
const refClass = state.inFor ? CLASS_REF_IN_FOR : CLASS_REF
const staticClassPath = paths.staticClass
if (staticClassPath) { // append
staticClassPath.node.value.value = staticClassPath.node.value.value + ' ' + refClass
} else { // add staticClass
path.node.properties.unshift(
t.objectProperty(t.identifier('staticClass'), t.stringLiteral(refClass))
)
paths.staticClass = path.get('properties').find(
propertyPath => propertyPath.node.key.name === 'staticClass'
)
}
return [
t.objectProperty( // data-ref="" ,头条 vue-ref
t.stringLiteral(state.options.platform.ref),
refPath.node.value
)
]
}
return []
}