草庐IT

vue指令

全部标签

javascript - Angular 2 错误- RC4 版本没有将 "exportAs"设置为 "ngModel"的指令

我在我的应用程序中使用了Angular2表单,并且我已经根据给定的链接创建了表单。https://angular.io/docs/ts/latest/guide/forms.html为了验证和使用表单API,我设置了ngModel值,如#name="id"#id="ngModel"并抛出脚本错误。但如果我将#id="ngModel"设置为#id="ngForm",它就解决了。但就我而言,我必须将模型值设置为ngModel。下面是我的html页面。EmployeeIDEmployeeIDisrequiredEmployeeNameEmployeeIDisrequiredDOJDOJisr

javascript - Vue.js - 应该使用哪个组件生命周期来获取数据?

在阅读了Alligator.io的一篇关于Vue的帖子后,它说挂载的生命周期不适合使用httpget。我想知道是否有关于如何在Vue.js中正确地从API获取数据的指南? 最佳答案 我更喜欢在创建的钩子(Hook)中调用API。引自alligator.io:Inthecreatedhook,youwillbeabletoaccessreactivedataandeventsareactive.TemplatesandVirtualDOMhavenotyetbeenmountedorrendered.因此,如果需要,您可以轻松访问数据

javascript - 如何将 vue.js 与 django 集成?

这是带有vue.js的单页应用程序,它进行了一些简单的计算,我试图在django中实现这个计算,但它没有给我想要的结果。在这里,我在vue.js中创建了动态数组,这只完美地显示了产品的图像,但没有显示product.name和product.sell_price以及@click.prevent="addToCart(product)"这个功能不起作用??我该如何解决?vue.jsnewVue({el:'#posApp',data:{total:0,discount:0,products:[{%forproductinproducts%}{"id":{{product.id}},"nam

javascript - Angularjs 分页指令

我正在尝试使用asimplePagination中使用的概念编写一个指令来生成分页链接prev和next链接是唯一生成的链接,单击它们会产生错误:UncaughtSyntaxError:Unexpectedtoken:这是fiddlehttp://jsfiddle.net/kelvo/zZURe/编辑1获得了要显示的其余链接,但双向绑定(bind)“=”似乎不起作用。这是新的fiddlehttp://jsfiddle.net/kelvo/zZURe/7/ 最佳答案 您正在更新Angular之外的一段代码,需要让Angular知道重新

javascript - Angular 1.5 中的组件和指令

Angular1.5中的重大功能变化正在周边支持components.component('myComponent',{template:'Hello{{$ctrl.getFullName()}}',bindings:{firstName:'虽然这一切都很好,但我不确定这与指令有何不同。与传统的自定义指令相比,使用components有什么好处?Angular1.5和Angular2中的组件是否相同? 最佳答案 .component不会像@rekŻelechowski所说的那样替换.directive。所以..没有什么是.compo

javascript - 测试 Vue.js 组件

我想测试一个Vue.js组件,但我失败了。简单地说,我正在设置一个组件属性,我想断言它设置正确。如果这很重要,模块将加载导出,并使用Webpack输出JS。//componentexports=module.exports={};module.exports={data:function(){return{active:false};},methods:{'close':function(){console.log(this.active);//->truethis.active=false;console.log(this.active);//->false}}};//compone

javascript - 从父级访问 Vue 中组件的计算属性

如何从父级访问Vue中组件的计算属性?在此示例中,我有一个包含商品组件的购物车,我想计算并显示购物车商品的总和:购物车.jsvarvm=newVue({el:'#cart',components:{cartItem:require('./components/cart-item.js'),},data:{items:[{name:'apple',qty:5,price:5.00},{name:'orange',qty:7,price;6.00},],},computed:{//IwanttodosomethinglikethisandaccesslineTotalfromcartcar

javascript - 动态注册本地 Vue.js 组件

我们知道possible像这样动态注册全局Vue.js(版本1)组件:Vue.component('my-component',MyComponent)有没有办法对本地组件执行相同的操作,即那些仅对特定组件可用/可见的组件?我的想法是,我希望能够像这样传递要在本地注册的组件:所以在outer-component中我可以做:created(){this.someMethodINeedToRegisterLocalComponent('cool-component',this.localComponentToBeRegisteredDynamically);},

javascript - 尝试通过 Vue.js 中的渲染传递 Prop 并观看它们

我在使用vue.js中的CreateElement/render将Prop从父级向下传递到创建的子级时遇到问题,然后再观看它。这是我的父组件Vue.component('my-drawing',MyDrawing)newVue({el:'#drawing',mounted(){Bus.$on('emitColorSelection',(emitString)=>{console.log("insidesocket.js/my-drawingandemitStringis",emitString);this.useColor=emitString;console.log('insides

javascript - 如何使用 Vue Slider 控制元素

我在requestsjson对象中有一堆数据。默认情况下,所有数据都会显示给用户。此外,我还有一个slider组件。我正在尝试实现这样的功能,即当用户移动slider时,json的元素会根据slider的值出现/消失。例如:数据:requests:[{value:10,name:"foo"},{value:12,name:"bar"},{value:14,name:"foobar"},{value:22,name:"test"},{value:1,name:"testtooo"},{value:8,name:"something"}]默认情况下,我希望显示所有数据,但当用户移动slid