草庐IT

http-vue-loader

全部标签

javascript - 为什么要将我的 $http 调用转移到服务中?

目前我的三个Controller上都有这样的调用:$scope.getCurrentUser=function(){$http.post("/Account/CurrentUser",{},postOptions).then(function(data){varresult=angular.fromJson(data.data);if(result!=null){$scope.currentUser=result.id;}},function(data){alert("Browserfailedtogetcurrentuser.");});};我看到很多建议将$http调用封装到Htt

javascript - Vue Js如何在单文件模板中使用mixins?

大家好,我是VueJS的新手,我正在尝试使用单个文件模板在我的过滤器上使用mixin,但我遇到了一些困难我得到的错误Unknowncustomelement:-didyouregisterthecomponentcorrectly?Forrecursivecomponents,makesuretoprovidethe"name"option.组件.jsVue.component('sideBarOne',require('./component/sidebars/sideBarOne.vue'));sideBarOne.vueimport{defaultasconfig}from'..

javascript - Vue.js : "TypeError: Cannot set property props of#<Object> which has only a getter"

我正在尝试实例化一个Vue组件,但出现错误:[Vuewarn]:Errorinrender:"TypeError:Cannotsetpropertypropsof#whichhasonlyagetter"(foundin)我也在使用库vuedraggable但我认为这个问题更多的是Vue问题而不是vuedraggable问题。下面是我的代码。这里是draggable-list.vue可拖动列表.jsconstdraggable=require("vuedraggable");module.exports={name:"draggable-list",components:{dragga

javascript - Angular.js 说自定义 HTTP 响应 header 为空

POST的回调函数为我的自定义HTTPheaderX-Auth-Token返回null。Chrome显示正确的POST响应header,但Angular.js不是。Angular唯一返回的是Cache-Control和Content-Type。其他一切都显示为空。这是我的CoffeeScript,展示了我是如何调用它的:.factory'loginFactory',($rootScope,$http,$resource)->$resource'/api/auth/login',email:'@id'password:'@id'.controller'userController',($

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 - JQuery 中的 HTTP Get 请求到 Last.fm

我正在尝试使用JQuery发出HTTPGet请求,但我得到一个空字符串作为响应,所以我认为我做错了什么。我使用了来自http://api.jquery.com/jQuery.get/的文档作为指南。我的代码是这样的$.get("http://www.last.fm/api/auth/?api_key=xxxkeyxxx",function(data){window.console.log(data);});编辑:我的代码现在看起来像这样$.getJSON("http://www.last.fm/api/auth/?api_key=c99ddddddd69ace&format=json&

javascript - Rails cookie 对象、Cookie HTTP header 和 document.cookie 之间的关系

当我在Javascript中访问document.cookie时,它吐出,说:'user_credentials=5beea8874f2db9feb873828'基本上,似乎是一些编码信息。很好。当我查看header时,我确实看到完全相同的字符串被设置为user_credentials,但还有另一个值被设置为_myapplication_session=BAh7CiIQX。与user_credentials不同,这个包括大写字母和F之后的字母。所以:什么是_myapplication_session?这与Rails中的session对象有关吗?为什么_myapplication_ses

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