Php 在vuejs中设置laravel变量
嗨,我有这个laravel php刀片代码Php 在vuejs中设置laravel变量,php,laravel,vue.js,vuejs2,Php,Laravel,Vue.js,Vuejs2,嗨,我有这个laravel php刀片代码 <tr v-for='line , id in edited_lines'> <td> @include( 'treats.create_search_and_select', [ 'search_and_select' => 'user_id[]', 'value' => nul
<tr v-for='line , id in edited_lines'>
<td>
@include(
'treats.create_search_and_select',
[
'search_and_select' => 'user_id[]',
'value' => null,
'hidden_id' => null,
'type' => 'all_type_of_accounts',
'required' => 'required',
'language' => 'account',
'hint' => null,
'policy' => null,
'show_type' => 'blank',
'rank' => null,
]
)
</td>
</tr>
所以我试过这个
'value' => "@{{line}}",
还有这个
'value' => "{{line}}",
没有一个是因为热爱工作。。
那么,如何设置值或隐藏的id from value from
非常感谢从Laravel到Vue共享(全局)变量的主要方法是:
- 通过窗口将状态变量传递给Vue应用程序(例如,用于用户信息)
- 将属性传递给组件
hidden_id
变量从Vue共享到Blade。我建议您根据代码片段和表行的内容制作一个组件,并在Vue中处理所有内容,而不是一半在Vue中,一半在blade中
使用状态变量,可以执行以下操作:
<html>
<head>
<script type="application/javascript">
window.state = {
my_js_var: '{{ $myPhpVar }}',
};
</script>
</head>
<body>
</body>
</html>
你不能这么做。PHP在服务器端编译/运行,而Vue在客户端(浏览器)编译/运行。
<html>
<head>
<script type="application/javascript">
window.state = {
my_js_var: '{{ $myPhpVar }}',
};
</script>
</head>
<body>
</body>
</html>