草庐IT

Vue-router

全部标签

javascript - $stateChangeStart 在 UI-Router ES6 中的状态变化时没有被触发?

我正在为ES6和webpack使用Bable。我在angular1.x.x上构建应用程序。到现在为止我没有遇到任何问题。我想要一个可以跟踪所有路线变化的功能。我正在使用UI路由器。问题是$stateChangeStart无论如何都不会被触发。代码如下。/*Allincludesaretakencareof.Pleaselookattherunmethod*/angular.module('chpApp',[uirouter,angular_animate,uibootstrap,formly,formlyBootstrap,ngMessages,angularLoadingBar,'n

javascript - 如何在同一个应用程序中使用 2 个具有不同 baseURL 的 Axios 实例 (vue.js)

我正在尝试学习vue.js,所以我制作了一个小应用程序来显示来自API的新闻文章,并在另一个View中允许用户登录到另一个服务器。为此,我使用Axios。我知道我在某些时候让它工作得很好,但今天开始我的项目时,让两个api同时工作是不可能的。这是我的登录服务:importaxiosTrainingAPIfrom'axios'axiosTrainingAPI.defaults.baseURL='https://api.example.com'consttrainingAPI={login(credentials){returnnewPromise((resolve,reject)=>{a

javascript - 使用 gulp 进行丑化时,Angular-ui-router 会中断

我有以下简单的angular.js应用程序,遵循概述的最佳实践here.angular.module('myApp',['ui.router']);(function(){functionroutes($stateProvider,$urlRouterProvider){$urlRouterProvider.otherwise("/404");$stateProvider.state('createCluster',{url:'/create-cluster',templateUrl:'templates/create-cluster.html'})}angular.module('m

javascript - 使用 react-router-redux 访问参数

我正在使用react-router-redux(https://github.com/ReactTraining/react-router/tree/master/packages/react-router-redux)安装npminstall--savereact-router-redux@next这样实现:我正在尝试访问容器中id的参数,如下所示:constmapStateToProps=(state,ownProps)=>{console.log(ownProps)return{...state.resource,id:ownProps.params.id}}如react-rou

javascript - Router.use() 需要中间件功能但未定义

我正在尝试设置我的Node服务器/RESTapi。为此我有几个不同的文件:division_model.js:module.exports=function(express,sequelize){varrouter=express.Router();router.route('/division');varDataTypes=require("sequelize");varDivision=sequelize.define('division',{id:DataTypes.INTEGER,organization_id:DataTypes.INTEGER,location_id:Dat

javascript - 在过滤器方法中访问 vue 实例/数据

我正在尝试像这样访问过滤器函数内的vue实例数据。JS:-newVue({data:{amount:10,exchangeRate:50},el:"#app",filters:{currency:function(amount){console.log(this);//returnamount*this.exchangeRate;returnamount*50;}}})HTML:{{amount|currency}}我的目标是使用returnamount*this.exchangeRate;但是this等于window这里。我怎样才能做到这一点?谢谢。jsfiddle

javascript - 每次使用 Router 时 Backbone.js 触发函数

只是想知道是否有一种简单的方法可以在每次使用Backbone.js路由器时触发自定义函数,而不必将其添加到每个路由器函数中。现在我的脚本看起来像这样:varAppRouter=Backbone.Router.extend({routes:{'':'index','test':'test',},initialize:function(){},index:function(){customFunction();indexView.render();},test:function(){customFunction();testView.render();},});我想要这样的东西:varAp

javascript/vue.js 接收json

我正在尝试像这样在我的vue.js应用程序中接收json:newVue({el:'body',data:{role:'',company:'',list:[],created:function(){this.getJson();},methods:{getJson:function(){$.getJSON('http://domain.dev/data',function(task){this.list=task;}.bind(this));}}}});但结果为空?当我在postman中对此进行测试时,url返回json。我在这里做错了什么?编辑:JSON(测试数据):{"Employ

javascript - Vue.js: 从 "parent"Vue 获取数据

我有一个(不可更改的)DOM结构如下:.........还有两个js文件:index.js:varchild=require('childVue');module.exports=newVue({el:'#indexVue',...});childVue.js:module.exports=newVue({el:'#childVue',methods:{something:function(){//Parentdataneededhere...},...}});如图所示,我需要indexVue的数据在childVue.有什么办法可以传递给它吗?我试图将它传递给带有(v-on="clic

vue中Element ui不生效

原因是我用的vue3不支持elementui要使用elementplus一个Vue3UI框架|ElementPlus(gitee.io)使用命令安装npminstallelement-plus--save安装完之后在main.js中编辑import{createApp}from'vue'importElementPlusfrom'element-plus'import'element-plus/dist/index.css'importAppfrom'./App.vue'constapp=createApp(App)app.use(ElementPlus)app.mount(‘#app’)即可