Meituan-Dianping/mpvue · error
style="${staticStyle}": Interpolation inside attributes has
Error message
style="${staticStyle}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div style="{{ val }}">, use <div :style="val">. What it means
Web platform style-attribute interpolation warning: style="{{ val }}" is unsupported since Vue 2. transformNode runs parseText on the static style attribute and warns in dev builds when delimiters are detected.
Source
Thrown at src/platforms/web/compiler/modules/style.js:19
/* @flow */
import { parseText } from 'compiler/parser/text-parser'
import { parseStyleText } from 'web/util/style'
import {
getAndRemoveAttr,
getBindingAttr,
baseWarn
} from 'compiler/helpers'
function transformNode (el: ASTElement, options: CompilerOptions) {
const warn = options.warn || baseWarn
const staticStyle = getAndRemoveAttr(el, 'style')
if (staticStyle) {
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production') {
const expression = parseText(staticStyle, options.delimiters)
if (expression) {
warn(
`style="${staticStyle}": ` +
'Interpolation inside attributes has been removed. ' +
'Use v-bind or the colon shorthand instead. For example, ' +
'instead of <div style="{{ val }}">, use <div :style="val">.'
)
}
}
el.staticStyle = JSON.stringify(parseStyleText(staticStyle))
}
const styleBinding = getBindingAttr(el, 'style', false /* getStatic */)
if (styleBinding) {
el.styleBinding = styleBinding
}
}
function genData (el: ASTElement): string {
let data = ''View on GitHub (pinned to 6c5d78ee04)
Solutions
- Use :style="styleObject" or :style="cssString" instead of interpolation.
- Compute units/width in JS: :style="{ width: w + 'px' }".
- Move static styles to a plain style attribute or CSS classes.
Example fix
// before
<div style="width: {{ width }}px">
// after
<div :style="{ width: width + 'px' }"> Defensive patterns
Strategy: validation
Validate before calling
function assertNoStyleInterpolationWeb (template) {
if (/style\s*=\s*["'][^"']*\{\{/.test(template)) {
throw new Error('Interpolation in style attr; use :style instead')
}
}
assertNoStyleInterpolationWeb('<div style="{{ s }}">') Type guard
const isStaticStyleWeb = (v) => typeof v === 'string' && !v.includes('{{'); Prevention
- Use :style bindings for dynamic inline styles
- Move static styles into CSS classes
- Lint templates in CI with eslint-plugin-vue
- Regex-scan migrations for style="{{
When it happens
Trigger: Compiling a template element with a static `style` attribute containing mustache delimiters (e.g. style="width: {{ w }}px") in dev mode.
Common situations: Vue 1 to Vue 2 migration; dynamically built inline styles in old code; templates from legacy libraries.
Related errors
- class="${staticClass}": Interpolation inside attributes has
- style="${staticStyle}": Interpolation inside attributes has
- class="${staticClass}": Interpolation inside attributes has
- ${name}="${value}": Interpolation inside attributes has been
- tag <${tag}> has no matching end tag.
AI-assisted analysis of Meituan-Dianping/mpvue@6c5d78ee04 (2026-09-02).
Data as JSON: /api/errors/57cd0b299425dd89.
Report an issue: GitHub.