{"record":{"id":"92eadef2eedc2e9d","repo":"Meituan-Dianping/mpvue","slug":"class-staticclass-interpolation-inside-attri-92eade","errorCode":null,"errorMessage":"class=\"${staticClass}\": Interpolation inside attributes has been deprecated. Use v-bind or the colon shorthand instead.","messagePattern":"class=\"(.+?)\": Interpolation inside attributes has been deprecated\\. Use v-bind or the colon shorthand instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/platforms/weex/compiler/modules/class.js","lineNumber":20,"sourceCode":"\nimport { parseText } from 'compiler/parser/text-parser'\nimport {\n  getAndRemoveAttr,\n  getBindingAttr,\n  baseWarn\n} from 'compiler/helpers'\n\ntype StaticClassResult = {\n  dynamic: boolean,\n  classResult: string\n};\n\nfunction transformNode (el: ASTElement, options: CompilerOptions) {\n  const warn = options.warn || baseWarn\n  const staticClass = getAndRemoveAttr(el, 'class')\n  const { dynamic, classResult } = parseStaticClass(staticClass, options)\n  if (process.env.NODE_ENV !== 'production' && dynamic && staticClass) {\n    warn(\n      `class=\"${staticClass}\": ` +\n      'Interpolation inside attributes has been deprecated. ' +\n      'Use v-bind or the colon shorthand instead.'\n    )\n  }\n  if (!dynamic && classResult) {\n    el.staticClass = classResult\n  }\n  const classBinding = getBindingAttr(el, 'class', false /* getStatic */)\n  if (classBinding) {\n    el.classBinding = classBinding\n  } else if (dynamic) {\n    el.classBinding = classResult\n  }\n}\n\nfunction genData (el: ASTElement): string {\n  let data = ''","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/src/platforms/weex/compiler/modules/class.js#L2-L38","documentation":"In the Weex template compiler, the class module detects interpolation ({{ }}) inside a static class attribute and warns that mixing interpolation into plain attributes is deprecated. The value is still parsed as dynamic (classResult), but you should migrate to v-bind:class / :class, which is the supported syntax.","triggerScenarios":"Compiling a Weex template containing class=\"btn {{activeClass}}\" or similar — the static class attribute contains {{...}} so parseStaticClass marks it dynamic, triggering the deprecation warning when staticClass is present.","commonSituations":"Templates copied from Vue 1.x code that allowed attribute interpolation; gradual Vue 1 → 2 migrations; hand-written templates mixing string concatenation habits with the new binding syntax.","solutions":["Replace attribute interpolation with the bind shorthand: :class=\"'btn ' + activeClass\" or :class=\"['btn', activeClass]\".","Move dynamic classes into the data model and use object/array syntax: :class=\"{ active: isActive }\".","Audit templates for {{ }} inside any attribute and convert them to v-bind/colon shorthand."],"exampleFix":"// before\nclass=\"btn {{activeClass}}\"\n// after\n:class=\"['btn', activeClass]\"","handlingStrategy":"validation","validationCode":"// lint-time guard for templates\nfunction hasAttributeInterpolation(tpl) {\n  return /(?:class|style)=\"[^\"]*\\{\\{/.test(tpl)\n}\n// fail CI if hasAttributeInterpolation(templateSource) is true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never put {{ }} inside plain attributes; use :class / v-bind:class.","Prefer object/array class syntax: :class=\"{ active: isActive }\".","Run vue/Weex compiler warnings in CI and treat deprecations as errors.","Update Vue 1.x templates when migrating to Vue 2."],"tags":["vue","weex","compiler","deprecation","class-binding"],"backgroundTag":"attribute-interpolation-deprecated","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}