longerpro

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

  •  
  •   longerpro · Feb 25, 2019 · 3429 views
    This topic created in 2815 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
    mchl
    Feb 25, 2019 via iPhone❤️1
    1
    const { api } = require(‘...’);
    SakuraKuma
    SakuraKuma
    Feb 25, 2019❤️1
    2
    module.exports = api..
    imherer
    imherer
    Feb 25, 2019❤️1
    3
    api.api.getUser
    longerpro
    longerpro
    OP
    Feb 25, 2019
    4
    明白了。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2340 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 12:47 · PVG 20:47 · LAX 04:47 · JFK 07:47
    ♥ Do have faith in what you're doing.