草庐IT

property-injection

全部标签

javascript - react : TypeError: Cannot read property 'propTypes' of undefined

请我为以下reactjs页面编写一个单元测试。exportdefaultclassCollapsibleextendsReact.Component{staticpropTypes={title:React.PropTypes.string,children:React.PropTypes.any,};render(){const{title}=this.props;return({title}{this.props.children});}}跟着啧啧Here我在下面写了我的测试describe('Collapsible',()=>{it('works',()=>{letrendere

javascript - 我可以像任何其他库一样将 JointJS 作为 AngularJS 模块注入(inject)吗?

我有一个带Angular应用程序,我需要使用这个库http://www.jointjs.com/,所以我下载了joint.min.js和joint.min.css并将它们的路由放在index.html中,但我不知道在app.js中放入什么来注入(inject)它,我不断从angular获取注入(inject)错误.这可能不是这样做的方法吗?我用谷歌搜索了很多但没有找到任何方法。我将不胜感激任何帮助,提前致谢! 最佳答案 如果您想在Angular应用程序中呈现Jointjs图表,那么这很容易做到。在我的例子中,我将Jointjs代码封

javascript - [Vue 警告] : Error in render function: "TypeError: Cannot read property ' first_name' of null"

我有以下Navigation.vue组件:{{user.first_name}}import{mapActions,mapGetters}from'vuex'exportdefault{name:'hello',methods:{...mapActions(['myAccount'])},mounted:function(){if(localStorage.getItem('access_token')){this.myAccount()}},computed:{...mapGetters(['user'])}}此代码返回:[Vuewarn]:Errorinrenderfunction

javascript - 未捕获的类型错误 : Cannot read property 'offsetWidth' of null

这个问题在这里已经有了答案:GoogleMAPAPIUncaughtTypeError:Cannotreadproperty'offsetWidth'ofnull(26个答案)OffsetWidthnullorundefined(Can'tfindsolution)[closed](1个回答)关闭8年前。不幸的是,我在发布这个问题之前阅读了几个线程,我找不到适合我的问题的答案。这是我的代码片段-->functionpopulateIframe(id){varifrm=document.getElementById(id);ifrm.src="business_data_to_excel

javascript - 了解 AngularJS Controller 中的依赖注入(inject)

刚刚学习依赖注入(inject),我想我开始理解它了。请告诉我我是否在正确的轨道上......例如:这两个是等价的吗?/*injectionmethod*/function($scope){}.$inject=['$scope'];/*othermethod*/varapp=angular.module('myApp');app.controller(,function($scope){}); 最佳答案 首先澄清一下:对于依赖注入(inject),无论您是使用全局函数声明Controller还是作为module.controller

javascript - 如何在 html-webpack-plugin 中注入(inject)自定义元标记?

我将Webpack与插件一起使用html-webpack-plugin.基于环境变量,我想注入(inject)标签进入最后index.html文件。我该怎么做? 最佳答案 您可以定义自己的模板。在WritingYourOwnTemplates中简要提到了它您可以将任何您想要的选项传递给它,并在带有htmlWebpackPlugin.options的模板中使用它们:htmlWebpackPlugin.options:theoptionshashthatwaspassedtotheplugin.Inadditiontotheoption

c# - JavaScript 运行时错误 : Unable to get property 'msie' of undefined or null reference

我刚刚尝试更改我对母版页的jqueryui引用。我只在InternetExplorer上收到上述错误。我在Firefox和Chrome上没有收到错误。这是抛出错误的jquery代码:returna.browser.msie?(b=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),c=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth),b我有下面的母版页:请让我知道我需要做什么?我尝试将jquery引

javascript - Angular2 - 类型错误 : Cannot read property 'Id' of undefined in (Typescript)

我收到以下错误:angular2.dev.js:23925EXCEPTION:TypeError:Cannotreadproperty'Id'ofnullin[{{product.Id}}inProductEditComponent@0:68]抛出://Product-edit.component.ts:import{Component}from'angular2/core';import{IProduct}from'./product'import{ProductService}from'./product.service'import{RouteParams}from'angula

javascript - react - 类型错误 : Cannot read property 'props' of undefined

我正在尝试创建一个能够删除列表中项目的点击事件,但是当我点击它时,我得到“类型错误:无法读取未定义的属性‘props’”。我尽量坚持使用ES6,而且我很确定在某处绑定(bind)“this”是一件好事,但我尝试了很多地方但都没有成功。importReact,{Component}from'react';import'./App.css';classAppextendsComponent{render(){return();}}classStreetFighterextendsComponent{constructor(props){super(props);this.state={ch

javascript - 将 $stateParams 和 $state 注入(inject) Jasmine Angular js 测试变得未定义

我正在为我的DetailCtrl编写jasmine测试。我有10个json文件,每个文件的文件名都是这样1.json2.json3.json在我的数据文件夹中这是我的详细控制backpagecontrollers.controller('DetailCtrl',function($scope,$stateParams,$http){$http.get('data/'+$stateParams.listingId+'.json').success(function(data){$scope.extrainfo=data;});});细节Controller正在从我的数据文件夹中获取每个1