【发布时间】:2020-05-14 06:29:39
【问题描述】:
我想知道如何将 laravel php 函数 lang 与 javascript 变量连接起来。 举个例子:
此代码无效。变量文本在 javascript 上是动态的。 php函数lang不翻译连词,显示reportParameter.txt_date
不工作显示reportParameter.txt_date
template: `
<div class="text-center mt-1">
<div class="custom-control custom-radio custom-control-inline" v-for="(text, val, index) in optionsParsed">
<input class="custom-control-input" type="radio" v-model="checked" :id="nomRadio+'_'+index" :name="nomRadio" :value="val" @change="getChecked(checked)">
<label class="custom-control-label" :for="nomRadio+'_'+index">@lang('reportParameter.'.@{{text}}')</label>
</div>
</div>
`
可以显示日期
template: `
<div class="text-center mt-1">
<div class="custom-control custom-radio custom-control-inline" v-for="(text, val, index) in optionsParsed">
<input class="custom-control-input" type="radio" v-model="checked" :id="nomRadio+'_'+index" :name="nomRadio" :value="val" @change="getChecked(checked)">
<label class="custom-control-label" :for="nomRadio+'_'+index">@lang('reportParameter.text_date')</label>
</div>
</div>`
问题是变量文本必须动态生成。问题只是我如何进行连接。我没有正确连接那里。我尝试了很多不同的方法,但都没有成功。
非常感谢您的帮助。
【问题讨论】:
-
让前端(vuejs)调用后端(laravel),得到你需要的数据。
标签: javascript php laravel vue.js