【问题标题】:looking to connect my ionic 4 project with pouchdb. But keep getting error 'can't access lexical declaration'希望将我的 ionic 4 项目与 pouchdb 连接起来。但不断收到错误“无法访问词法声明”
【发布时间】:2020-08-24 22:31:43
【问题描述】:

当我尝试访问此页面时,我不断收到“无法访问词法声明”错误,但当我评论 pouch db 语句时它工作正常。

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import PouchDB from 'pouchdb';

@Component({
  selector: 'app-newperson',
  templateUrl: './newperson.page.html',
  styleUrls: ['./newperson.page.scss'],
})
export class NewpersonPage implements OnInit {

  private name;
  private email;
  private phone;
  private db;

  constructor(
    private router : Router
  ) {
    // this.setupDB();
  }

  setupDB() {
    this.db = new PouchDB('contacts');
  }

  ngOnInit() {
    // console.log(PouchDB);
    
    this.setupDB();
    this.name = 'John Doe';
  }

  goBack() {
    this.router.navigate(["/home"]);
  }

  save() {
    // this.db.post({
    //   name: this.name,
    //   email: this.email,
    //   phone: this.phone
    // })
    console.log('save clicked');
    
  }

}

我现阶段的主要目标是刚刚开始使用 pouchdb。还有 youtube 视频链接:- https://www.youtube.com/watch?v=HWbsN1QIIN8&t=1693s

【问题讨论】:

    标签: ionic-framework pouchdb


    【解决方案1】:

    只是确保。您是否将 pouchdb 添加到您的离子项目 package.json 中?在我的项目中,db 被定义为 any。

    私有数据库:任意;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-21
      • 1970-01-01
      • 1970-01-01
      • 2012-08-11
      • 1970-01-01
      相关资源
      最近更新 更多