草庐IT

Vue自定义指令

全部标签

javascript - Firebase 未定义?

我正在开发一个Angular项目并使用Firebase,它出现错误并显示ReferenceError:Firebaseisnotdefined,但我不明白为什么。这是我的index.htmlMyContactsAppmyContacts我的contact.js'usestrict';angular.module('myContacts.contacts',['ngRoute','firebase']).config(['$routeProvider',function($routeProvider){$routeProvider.when('/contacts',{templateUr

javascript - 如何在 React Native 中按百分比定义宽度?

我正在尝试创建一个带有边框的View,该边框居中并填充屏幕的80%。我想出了这个:这有效,但看起来非常冗长。是否有更好(更简洁)的方法来创建占屏幕宽度一定百分比并位于页面中心的View? 最佳答案 更新:从ReactNative版本0.42开始,我们现在对width、height、padding等提供完整的百分比支持,请参阅完整的在此处列出和示例:https://github.com/facebook/react-native/commit/3f49e743bea730907066677c7cbfbb1260677d11旧方法:考虑

javascript - Angular 2 中的指令执行顺序

如果我有一个带有点击处理程序和自定义属性指令的简单按钮,如下所示:Save在我的属性指令中,我使用hoSTListener装饰器来监听点击事件:@Directive({selector:`[attributedirective]`})exportclassAuditPusher{@Input('attributedirective')attributedirective:string='Missingmessage!';@HostListener('click',['$event'])pushAudit(){console.log('text:'+this.attributedirec

javascript - 我如何检查 object.property 是在 Angular 2 中定义的?

Angular2中是否有与Angular1中的angular.isDefined等价的函数勾选安全导航运算符?.,仅在tempalte中支持 最佳答案 Typescript没有检查变量是否定义的函数,Angular2也没有。使用杂耍检查,您可以一次测试null和undefined:if(object.property==null){如果您使用严格检查,它只会对设置为null的值为真,而不会对undefinedvariable求值为真:if(object.property===null){

javascript - 带有 vuex 的 Vue js 使用 v-for 和 v-model 计算属性

我需要将v-for与v-model结合使用。我读了docs并且没有示例说明如何在不在变异处理程序之外执行变异的情况下将它与v-for一起使用。如何在不直接改变属性的情况下在v-for中使用v-model?0{{n}}//componentmethods:{...mapMutations({addToCart:ADD_TO_CART})}, 最佳答案 不确定我是否完全理解您的问题,但请查看以下内容:编辑已更新为使用Vuex-但不是通过v-model,因为那样不会调用所需的突变或操作conststore=newVuex.Store({s

javascript - 单击时如何从 Controller 获取数据到指令

当我使用ng-clicked时,我试图从Controller将数据发送到指令链接函数,但是我未能将数据发送到指令,该指令在页面加载时调用第一次这是我的html代码click这是我的Controller.controller('myController',function($scope){$scope.clickMe=function(somedata){$scope.myVal=somedata;};});我的指令.directive('myDirective',function(){return{restrict:'E',scope:{myKey:'='},templateUrl:'

javascript - AngularJS FileUpload 中未定义内容类型的用途

为了将文件从Angular上传到SpringMVCRESTWebService,人们似乎在AJAX请求中设置Content-Type:undefinedheader。这种content-type的用途是什么,SpringMultiPart是否需要它?$http.post(uploadUrl,fd,{transformRequest:angular.identity,headers:{'Content-Type':undefined}//...} 最佳答案 它将重置默认header“application/json”并让浏览器为我们填

javascript - 使用指令将组件动态添加到子元素

尝试使用指令将组件动态放置到子元素。组件(作为模板):@Component({selector:'ps-tooltip',template:`{{content}}`})exportclassTooltipComponent{@Input()content:string;}指令:import{TooltipComponent}from'./tooltip.component';@Directive({selector:'[ps-tooltip]',})exportclassTooltipDirectiveimplementsAfterViewInit{@Input('ps-toolti

javascript - Vue.js:根据方法对列表进行排序

我正在获取一些原始数据并显示项目列表。每个项目都有一个我用方法生成的复杂属性(不是计算属性)。该属性可能会根据用户输入而改变。是否可以根据该属性对列表项进行排序?HTML:{{calculateComplexProperty(item.time)}}JavaScript:calculateComplexProperty:function(time){//this.distanceisanexternalfactorthatisnotapropertyofthelistitem,//andthatcanbemanipulatedbytheuservarspeed=time*this.di

javascript - Angular 2 - 在 iframe 上注入(inject)自定义 header

我疯狂地尝试将请求自定义header(类似于'AUTH-TOKEN':'SomeToken123')注入(inject)到Angular4上。我需要向iframe页面传递一些必需的自定义header参数。谁能帮帮我?foo.component.html组件.ts@Component({selector:'app-foo',templateUrl:'./foo.component.html'})exportclassFooComponentimplementsOnInit{@ViewChild('iframe')iframe:ElementRef;publicisLoading:Bool