小编Riy*_*enz的帖子

解析器发射错误`ERROR错误:"[object Object]"`

我在路由上实现解析器时遇到问题,因为InitialDataResolver在我的路由模块上包含它之前没有问题.

页面,routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { FrontComponent } from '../layouts/front/front.component';
import { HomeComponent } from './home/home.component';
import { DocsComponent } from './docs/docs.component';
import { InitialDataResolver } from './../shared/resolvers/initial-data.resolver';

const routes: Routes = [
  {
    path: '',
    component: FrontComponent,
    children: [
      { path: '', component: HomeComponent },
      { path: 'docs', component: DocsComponent }
    ],
    resolve: {
      init: InitialDataResolver
    },
  }
];

@NgModule({
  imports: [ RouterModule.forChild(routes) ],
  exports: [ …
Run Code Online (Sandbox Code Playgroud)

angular angular-resolver

27
推荐指数
2
解决办法
2万
查看次数

Googe Maps:无法读取未定义的属性'setDirections'

我是使用Google Maps API的初学者,我只想在下面的错误方面提供一些帮助:

Uncaught TypeError: Cannot read property 'setDirections' of undefined
at eval (google-maps.vue?1cba:101)
at directions.js:8
at gm.j (directions.js:5)
at Object.c [as _3lwmum] (common.js:46)
at VM1924 DirectionsService.Route:1
Run Code Online (Sandbox Code Playgroud)

这是我实现Directions API的代码

getRoute() {
  this.directionsService = new google.maps.DirectionsService()
  this.directionsDisplay = new google.maps.DirectionsRenderer()
  this.directionsDisplay.setMap(this.$refs.googleMap.$mapObject)
  this.directionsService.route({
    origin: this.location.position,
    destination: { lat: 62, lng: 15 },
    travelMode: 'DRIVING'
  }, function (response, status) {
    if (status === 'OK') {
      this.directionsDisplay.setDirections(response)
    } else {
      console.log('Directions request failed due to ' + status)
    }
  })
},
Run Code Online (Sandbox Code Playgroud)

这就是'this.$ refs.googleMap.$ mapObject'的值

这个.$ refs.googleMap.$ mapObject值

google-maps google-api directions vue.js vuejs2

2
推荐指数
1
解决办法
543
查看次数