简体   繁体   English

使用 Vue.JS “操纵” Laravel 刀片表单

[英]"Manipulate" Laravel Blade Form with Vue.JS

I could use some help to understand the fundamentals between Blade views and the use of Vue.JS in combination.我可以使用一些帮助来理解 Blade 视图和结合使用 Vue.JS 之间的基础知识。

I have a form which is created by a Blade Template.我有一个由刀片模板创建的表单。

文本

I now want to help the user filling out the form by pre-filling the "End-Date" depending on which duration he chooses in the dropdown.我现在想通过预先填写“结束日期”来帮助用户填写表格,具体取决于他在下拉列表中选择的持续时间。 Also, if he chooses "no duration", the End-Date should be hidden and so on.此外,如果他选择“无持续时间”,则应隐藏结束日期等。

Now i don't have experience with JavaScript.现在我没有使用 JavaScript 的经验。 It should be possible to do things like this with JQuery but as far as i understand, Laravel and Vue.JS seem to be a good combination.应该可以用 JQuery 做这样的事情,但据我了解,Laravel 和 Vue.JS 似乎是一个很好的组合。 So i wanted to go with it.所以我想用它来 go 。

I don't understand how to combine Blade with Vue.我不明白如何将 Blade 与 Vue 结合使用。

Can i just add things like <p>@{{ message }}</p> into the template?我可以将<p>@{{ message }}</p>之类的内容添加到模板中吗? I tried this, but where has the JavasScript-Code to go?我试过这个,但是 go 的 JavaScript 代码在哪里? Putting it in the app.js gives me a warning:把它放在 app.js 中会给我一个警告:

[Vue warn]: Property or method "message" is not defined on the instance but referenced during render. [Vue 警告]:属性或方法“消息”未在实例上定义,但在渲染期间被引用。 Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.通过初始化该属性,确保该属性是反应性的,无论是在数据选项中,还是对于基于类的组件。 See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties .请参阅: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties

I've been reading of Vue-Components, but putting the whole form or parts of it into a component would Blade prevent to render the form, correct?我一直在阅读 Vue-Components,但是将整个表单或其中的一部分放入组件中会阻止 Blade 呈现表单,对吗?

Maybe you could help me into the right direction.也许你可以帮助我走向正确的方向。 Thanks alot.非常感谢。

First Of all you need to know the basics of JavaScript.首先,您需要了解 JavaScript 的基础知识。 Although you had jumped to js framework that will not help you.尽管您已经跳到 js 框架,但这对您没有帮助。 Learn js first.先学js。 If you only want to maintain the End-date by the duration, it can be done by basic js or jquery.如果只想通过duration来维护End-date,可以通过基础js或者jquery来实现。 You don't need to adjust vuejs.你不需要调整 vuejs。 Rather if you being compelled to vuejs, it can be done on a component and can be rendered by catching an id of any div tag...相反,如果您被迫使用 vuejs,它可以在组件上完成,并且可以通过捕获任何 div 标签的 id 来呈现......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM