打字稿无法找到'需要使用Ionic2设置pouchdb

时间:2016-06-21 08:20:18

标签: angularjs typescript ionic-framework pouchdb

我也尝试按照教程 How To Use PouchDB + SQLite For Local Storage In Ionic 2 ,这似乎是使用带有Angular 2 / Ionic 2的pouchdb的一个很好的切入点。我的操作系统是OSx

能够安装打字后需要' ionic serve抛出:

TypeScript error: (...) Error TS2304: Cannot find name 'require'.

我关注了installing typings require failed in macOSXInstall Typings require for Ionic2 application主题,但它并没有帮助我。 (除了更好地理解' TypeScript')

需求文件位于:

/ionic2-tutorial-pouchdb/typings/globals/require

任何想法?关于'安装的教程需要'不适合我。

thx Pitt

1 个答案:

答案 0 :(得分:0)

我猜你有一行代码如:

  a <- c("A","B","C")

  Choices <- as.character(a)

  ui <- fluidPage(
    fluidRow(
      selectInput(inputId = "numfields", label = "Select Entries", choices = Choices, multiple = TRUE, selectize = TRUE),
      conditionalPanel(
          condition = "count(input$numfields) >= 1",
          textInput(inputId = "field1", label = "First One", value = "")
        ),
      conditionalPanel(
        condition = "count(input$numfields) >= 2",
        textInput(inputId = "field2", label = "Second One", value = "")
      ),
      conditionalPanel(
        condition = "count(input$numfields) >= 3",
        textInput(inputId = "field3", label = "Third One", value = "")
      )
      )
    )

  server <- function(input, output, session)
  {}

  shinyApp(ui=ui, server=server)

您无需使用require导入Angular2。相反,你应该像这样使用import:

let PouchDB = require('pouchdb');

Reference from one of the GitHub issues on the PouchDB GitHub account

您提供的链接也使用import而不是require。此外,在较新版本的打字稿中,打字已被@Types替换。