草庐IT

nodejs_vue

全部标签

javascript - Vue debounce 一个方法?

我知道Vue.js具有内置的功能来消除输入字段的抖动。我创建了一个slider来触发一个不使用输入字段的方法,我想知道我是否可以利用方法内部的去抖动功能。除了简单地向输入添加去抖动之外,是否有可能使用此功能?还是我需要为此编写自己的功能?我刚刚试过做这样的事情,但它似乎不起作用:this.$options.filters.debounce(this.search(),2000); 最佳答案 对于任何想知道如何做到这一点的人。我通过使用我发现的一个很棒的小片段修复了这个问题:我的数据中的属性timer:0去抖动功能//clearsth

javascript - Spring stomp websockets with vue.js

我正在尝试将Springwebsockets(STOMP)与Vue结合使用,但不知道该怎么做,甚至不知道该怎么做。我的websockets使用纯JS,但是当我尝试使用Vue时,我卡住了。这是我的Vue代码:varapp=newVue({el:'#app',data:{stompClient:null,gold:0},methods:{sendEvent:function(){this.stompClient.send("/app/hello",{},JSON.stringify({'name':$("#name").val()}));}},created:function(){this

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 - Vue - 使用 refs 来聚焦元素目标

点击spanclass="before-click"时,我想隐藏它,而是显示inputclass="after-click"。并且出现的输入标签必须是焦点!问题是当我尝试使用$refs.afterClick访问那个DOM并给它.focus()时,一个意外错误显示.focus()不是一个函数。如何解决这个问题?谢谢。varmyApp=newVue({el:'#app',data:{onEdit:false,msg:'Somethinginhere',},methods:{switchAndFocus(){if(!this.onEdit){this.onEdit=true;this.$re

javascript - 数据更新后触发的 Vue.js 事件

我有一个Vue.js应用程序,我有几个组件用于处理一些重复性任务。我还从AJAX请求中获取数据。我想要一些输入是,如果有一个事件在Vue数据(treeData和flatTreeData)被更新和操作后触发,以便我可以执行还有其他操作吗?varapp=newVue({el:'body',data:{treeData:{items:{}},flatTreeData:[],},});$.getJSON('./paths.json').done(function(data){//applythefilestructuretothevueappdemo.treeData=data;demo.fl

javascript - Vue mousemove 仅在 mousedown 之后

如何仅在先单击元素时才触发mousemove?我正在尝试将其用于音频播放器时间轴。.player__time--bar(@mousedown="setNewCurrentPosition($event)").slider(role="slider"aria-valuemin="0":aria-valuenow="currentPosition":aria-valuemax="trackTotalDuration"aria-orientation="horizontal").player__time--bar-current-position(:style="{width:(100/(t

javascript - Vue 2 - 如何在 Prop 中设置默认数组类型

我有我的Vue组件,它以一组对象作为Prop。我经常使用prop验证,尤其是对于“默认”值功能。在这种情况下,我有:props:{items:Array}但我希望它像Typescript或React一样:props:{items:Array.of({key:{type:String,default:'myText'}})}等等有可能实现吗?否则我需要使用计算数据作为map来设置默认值 最佳答案 我创建了示例:jsFiddle,这可能会对您有所帮助,是的...您可以将默认值作为数组返回:ES6props:{items:{type:Ar

javascript - 如何在vue中创建警告确认框

我想在删除文件之前显示一个对话框,我如何使用vue做到这一点?这是我的尝试我的删除文件按钮Delete这是我的删除方法DeleteUser(id,index){axios.delete('/api/artist/'+id).then(resp=>{this.artists.data.splice(index,1);}).catch(error=>{console.log(error);})},对话框正在显示,但无论我选择什么,它都会继续删除文件。 最佳答案 试试这个DeleteDeleteUser(id,index){if(conf

javascript - Vue.js 拦截器

如何在vue.js中使用拦截器?所以在每个请求/响应之前,它应该首先去拦截器。我已经搜索了很多,但找不到相关的好文档。我想像这样使用JWTAuth:(function(define){'usestrict'define(function(require){varinterceptorinterceptor=require('rest/interceptor')/***AuthenticatestherequestusingJWTAuthentication**@param{Client}[client]clienttowrap*@param{Object}config**@return

javascript - 如何使用 nodejs express 应用程序配置 eslint

js应用程序。我需要为此应用程序使用eslint。我正在使用https://www.npmjs.com/package/eslint-config-airbnb并在VSCode编辑器中使用更漂亮的插件。.eslintrc{"extends":"airbnb"}我看到在添加eslint插件后VSCode现在在整个项目中给我很多错误https://marketplace.visualstudio.comitems?itemName=dbaeumer.vscode-eslint和npm包。很少有错误[eslint]Definitionforrule'jsx-a11y/href-no-hash