草庐IT

prop-types

全部标签

javascript - Vue.js Prop 、组件和数据命名空间

当我有一个Vue.js组件时,它可能看起来像:importIconfrom'./Components/Icon.vue'exportdefault{props:{data:{type:Object}},data(){return{label:this.data.label||'',icon:this.data.icon||'',placeholder:this.data.placeholder||'',value:this.data.value||'',disabled:this.data.disabled||false,readOnly:this.data.readOnly||fal

javascript - 表达 : typescript: Argument of type 'typeof <express.Router>' is not assignable to parameter of type 'RequestHandlerParams'

我将expressjs与最新的typescript定义文件和来自https://github.com/DefinitelyTyped/DefinitelyTyped的typescript2.3.4一起使用.我定义了一个路由器,并希望按照官方4.x文档(app.use('/calendar',router);)中的说明从子路径使用它,但出现以下错误Error:/Users/matthias/Documents/privateworkspace/universal/src/server/server.ts(161,34):Argumentoftype'typeof"/Users/matth

javascript - 如何将 Typed.js 与 Angular 2 集成?

我会使用Typedjs在Angular2中制作打字机效果如site所示页面,我已经用npm安装了包:npminstalltyped.js然后我将这段代码添加到我的组件中:importTypedfrom'typed.js';//notsureifit'stherightway和ngOnInit(){vartyped=newTyped(".element",{strings:["ThisisaJavaScriptlibrary","ThisisanES6module"],smartBackspace:true//Defaultvalue});}然后在我的html文件中:Typed.jsis

javascript - this.props.history 已弃用( react 路由器)

我试图以编程方式导航到另一个页面,就像这样this.props.history.push('/new-path');它有效,但我在控制台中收到弃用警告说:警告:[react-router]props.history和context.history已弃用。请使用context.router。此处有更多信息https://github.com/reactjs/react-router/blob/master/upgrade-guides/v2.0.0.md#changes-to-thiscontext之后我尝试像这样使用这个新方法this.context.router.push('/new

javascript - 在 TSX 文件 : Property 'createRef' does not exist on type 'typeof React'

我需要组件的引用。刚刚从jsx转移到tsx并找不到解决这个问题的方法。其他解决方法是使用查询选择器,但我认为这不是做react的好方法。这里是构造函数constructor(props){super(props);this.state={data:initialData,showNewListForm:false,whichButtonClicked:undefined,background:props.background||"#23719f"};this.divContainerRef=React.createRef();console.log("kanbanreference:"

javascript - 如何解决错误 "Did not load script at ' 脚本名称',因为在给出 'X-Content-Type: nosniff' 时不允许使用非脚本 MIME 类型

我有一个相当简单的Angular1.x应用程序,在我升级到Safari11之前它运行良好。现在,它不起作用,因为几乎所有的js文件都被阻止了。CSS文件也是如此,但删除“rel”属性并添加type="text/css"解决了CSS问题。对于JS文件,我确保将type="text/javascript"添加到脚本标签中。我也只是尝试将./添加到src的开头以获取笑声,但它们仍然无法加载。有人知道如何解决这个问题吗?谢谢,韦恩 最佳答案 我只想删除这个问题,但我希望这个答案可能对某些人仍然有帮助。所以,我的问题实际上是我的项目克隆不好,

javascript - Vue - 使用 Prop 将类名添加到组件

我想使用以下Prop在Vue中制作一个自定义组件:text=要在链接中显示的文本。icon=显示在链接旁边的图标的标识符。我的组件有以下.Vue模板。{{text}}exportdefault{props:['text','icon'],data(){return{}}}本质上,我的模板中有默认的Font-Awesome代码:我想通过使用它的prop向我的组件添加一个类。谢谢。 最佳答案 因此,当您的属性icon持有值home时,您可以像下面这样使用一些类绑定(bind)(谢天谢地,在Vue.js中attributes中允许使用js

javascript - typescript : Type 'Promise<{}>' is not assignable to type 'Promise<void>'

我有以下功能:lettemplateLoader=(onDidFinishLoad:Function,onDidFailLoad:Function)=>(url:string):Promise=>newPromise((resolve,reject)=>{mainWindow.loadURL(url);mainWindow.webContents.once('did-finish-load',()=>{onDidFinishLoad(resolve);});mainWindow.webContents.once('did-fail-load',(event,errorCode,erro

javascript - 如何将 Prop 传递给组件的故事?

我想为vue-select添加一些故事组件使用Storybook,但我正在努力处理更复杂的案例,其中涉及传递Prop或方法。当我在模板内传递Prop时它起作用:storiesOf('VSelect',module).add('withlabeledcustomoptions',()=>({components:{VSelect},template:``}))我发现它的可读性不是很好,所以我想将它们分别作为props或data传递:.add('withlabeledcustomoptionsasprops',()=>({components:{VSelect},props:{option

javascript - "$attrs is readonly", "$listeners is readonly", "Avoid mutating a prop directly"

我是Vue新手。我正在尝试开发一个聊天应用程序,其中好友列表将显示在左侧菜单上,聊天框将显示在正文中。我正在使用ajax调用加载好友列表,并根据好友ID路由到聊天框。这是代码示例。聊天列表组件将从服务器加载好友列表。这是我的app.js文件;Vue.use(VueRouter)constrouter=newVueRouter({routes,linkActiveClass:"active"});importChatComponentfrom'./components/ChatComponent';constroutes=[{path:'/chat/:id/:name',componen