前提・実現したいこと
Vue.jsからtwigを利用して、バリデーションのエラーメッセージを表示したいです。
以下のname部分を「{% for item in name %}」中のitemに置き換えたいですが、記述方法が上手くいかず困っています。
変更前のソースコード
php
1 {% verbatim %}<p class="errorText" v-if="errors.hasOwnProperty('name') && errors.lastname!== ''">※{{ errors.name}}</p>{% endverbatim %} 2 {% if errors.has('name') %}<p class="errorText" v-if="!errors.hasOwnProperty('name')">※{{errors.first('name')}}</p>{% endif %}
試したこと
エラーメッセージ
Property or method "item" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
{% for item in name %} {% verbatim %}<p class="errorText" v-if="errors.hasOwnProperty('{{ item }}') && errors.{{ item }} !== ''">※{{ errors.{{ item }} }}</p>{% endverbatim %} {% endfor %}
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。