草庐IT

vue-template-compiler

全部标签

javascript - Vue (nuxt) 中的全局组件

在构建Vue应用程序时,我们在每个模板中重复使用某些Vue组件。我们的网格系统存在于.region、.layout、.grid、.column元素之外。它们都是独立的Vue组件(,...)。我们现在在每个模板中都这样做:importBlMainfrom'~components/frame/main/Main.vue'importBlRegionfrom'~components/frame/region/Region.vue'importBlLayoutfrom'~components/frame/layout/Layout.vue'importBlGridfrom'~component

javascript - 无法直接在 ng-template 中访问范围变量

所以我最近将一些重复的标记移到了ng-templateblock中,我注意到在block内部,我无法直接访问作用域变量,但我仍然可以调用作用域函数。例如,考虑以下标记:IToggletheFlagIDoNothingTheflagis{{flag}}与以下脚本配对:varapp=angular.module('myApp',[]).controller("myController",['$scope',function($scope){$scope.flag=true;$scope.toggleFlag=function(){$scope.flag=!$scope.flag;}}])此

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