Вы не можете сделать это с простым синтаксисом привязки данных.Вам нужно будет использовать кастом directive
.Это будет выглядеть следующим образом.
<input :name="field.name" v-data-binder="field.dataAttributes" />
Ваше определение директивы будет выглядеть примерно так:
// Register a global custom directive called `v-focus`
Vue.directive('data-binder', {
// When the bound element is inserted into the DOM...
inserted: function (el, binding) {
// Perform data attribute manipulations here.
// 1. Parse the string into proper key-value object
// binding.value
// 2. Iterate over the keys of parsed object
// 3. Use JavaScript *dataset* property to set values
}
})
Вам также понадобится хук updated
в определении директивы для удаления существующих data - * атрибуты всякий раз, когда значение, переданное директиве, изменяется.