草庐IT

Vue——patch.ts【十四】

全部标签

javascript - 使用 Vue.js 播放声音

如何使用Vue.js播放声音?似乎我不能只做常规的方式。importVuefrom'vue'importAppViewfrom'./components/App.vue'console.log('Playoutsideofvue')varaudio=newAudio('file.mp3')audio.play()newVue({el:'#root',mounted(){console.log('Willitplayhere??lol')varaudio=newAudio('file.mp3')audio.play()},render:h=>h(AppView)})正如它所说,音频未定义

javascript - 在 vue 路由中匹配查询参数

有什么方法可以通过查询参数进行路由吗?我想匹配以下路由:site.com/?foo=123。我试过类似的东西{path:'/\?foo=[\d]*'}没有成功。 最佳答案 不幸的是,您无法匹配路由定义的path字符串中的查询参数。VueRouter使用path-to-regexp和itsdocumentation说:TheRegExpreturnedbypath-to-regexpisintendedforusewithpathnamesorhostnames.Itcannothandlethequerystringsorfragm

javascript - typescript + moment.js : error TS2307: Cannot find module 'moment'

我正在开发一个网络应用程序,使用angular1.5、typescript2.4.0、moment:2.18.1和gulp进行项目组装。这是我的tsconfig.json:{"files":["src/app/main.ts","types/**/*.ts"],"compilerOptions":{"noImplicitAny":false,"target":"es2015","allowSyntheticDefaultImports":true}}在我的date-range-picker.component.ts中。我正在导入时刻库,正如maindocumentation中所建议的那

javascript - 如何将弹出框内的输入标签绑定(bind)到 Vue 模型

我在弹出内容中有一个input,如下所示:JSFiddleHTML:'>ClickMe!{{message}}这是JS:newVue({el:'#vue-app',data:{message:'IamaText'}});$(document).ready(function(){$('[data-toggle="popover"]').popover();});如您所见,data-content的输入绑定(bind)得很好,但里面的输入没有绑定(bind)!任何想法将不胜感激。 最佳答案 你可以这样使用:这是工作演示:https://

javascript - 如何从父组件将类应用到 Vue.js 功能组件?

假设我有一个功能组件:Somefunctionalcomponent现在我在一些带有类的父级中渲染这个组件:结果DOM没有将new-class应用于Functional子组件。现在据我了解,Vue-loader将Functional组件针对render函数context编译为explainedhere.这意味着类不会被直接应用和智能合并。问题是-如何在使用模板时让函数式组件与外部应用的类很好地配合?注意:我知道可以通过渲染函数轻松实现:Vue.component("functional-comp",{functional:true,render(h,context){returnh("

javascript - 在 VUE 中切换样式时边框样式无法正确呈现

检查这个demo下面:newVue({ el:'#app',data:{ flag:true},computed:{ style(){letstyleA={borderBottom:'1pxsolidred',borderRight:'1pxsolidred'};letstyleB={ border:'1pxsolidgreen',borderRight:'1pxsolidred'}returnthis.flag?styleA:styleB}},methods:{ changeStyle(){ this.flag=!this.flag;}}}).box{width:100px;heig

javascript - 如何使用谷歌浏览器调试 Vue 应用程序

我想摆脱一直使用console.log并更频繁地使用Chrome开发者调试工具。我觉得这很好Howtostopusingconsole.log()andstartusingyourbrowser’sdebugger关于一般调试(设置断点、逐行执行等)但是当我尝试在现实生活中使用它时——这意味着在我正在处理的vue(nuxt)应用程序中使用它——我无法让它工作。我的所有文件都组合成更复杂的javascript文件,我无法对其进行调试。然后我找到了这个帖子:Debugging.vuecomponentinChrome我认为这会阐明这件事,但不幸的是我不知道该怎么做。我添加了这个:confi

javascript - 我似乎在用 Javascript 完全创建一个变量之前使用它,但这行得通——为什么?

有人能给我解释一下吗?vardiagramImage=newKinetic.Shape(function(){varcontext=this.getContext();context.beginPath();context.lineWidth=1;//Thisiscrazytricks.It'spartoftheKineticJSdemowebsite,buthowamIabletoassigndiagramImage.colorhere?context.strokeStyle=diagramImage.color;varlastVertice=polygon.Vertices[pol

javascript - Angular 到 Aurelia 的过渡——一些基本问题

我们正在考虑将Aurelia用于新应用。我来自Angular1背景(接触过Angular2)。Aurelia看起来相当不错,我真的很喜欢他们如何承担起维护开发人员工作流程的责任。但是我有一些问题似乎无法找到答案:1)有两种一般方法(据我所知)可以在页面中包含Web组件。这些是并编写自定义元素。我的问题是,Angular非常强调作用域(即DOM中特定点的作用域)。我想知道“范围”中有什么(即可用于绑定(bind)表达式)与组合和自定义元素。我的意思是,子模板中是否有父View模型?如果是这样,subview模型属性是否隐藏/隐藏父View模型属性?2)在Angular2中,有关于如何将数

javascript - Vue.js 访问父组件

我有一个具有此方法的子组件:getSubscriptions(){MessageService.subscriptions()this.$parent.loading=true;.then((data)=>{if(data.data.subscriptions==null){this.noSubscriptions=true;}else{this.subscriptions=data.data.subscriptions;}this.$parent.loading=false;}).bind(this);}所以我想在我的父组件中显示一个加载圆,我这样访问它:this.$parent.l