longerpro

在看微信小程序,遇见个应该是 JS 的问题,求解

  •  
  •   longerpro · Feb 25, 2019 · 3115 views
    This topic created in 2660 days ago, the information mentioned may be changed or developed.

    在 api.js 中定义了 getUser() 方法。

    index.js 是小程序的首页,在 onLoad() 生命周期中调用 getUser() 方法。

    一直报错 TypeError: api.getUser is not a function。

    啥原因呢?

    api.js index.js

    4 replies    2019-02-25 12:36:43 +08:00
    mchl
        1
    mchl  
       Feb 25, 2019 via iPhone   ❤️ 1
    const { api } = require(‘...’);
    SakuraKuma
        2
    SakuraKuma  
       Feb 25, 2019   ❤️ 1
    module.exports = api..
    imherer
        3
    imherer  
       Feb 25, 2019   ❤️ 1
    api.api.getUser
    longerpro
        4
    longerpro  
    OP
       Feb 25, 2019
    明白了。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5354 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 60ms · UTC 09:02 · PVG 17:02 · LAX 02:02 · JFK 05:02
    ♥ Do have faith in what you're doing.