如何在Nuxt.js创建的Capacitor App中请求API

问题描述 投票:0回答:1

我通过现有的 Nuxt.js 项目创建了 Capacitor App,并使用通过执行

dist
生成的
nuxt generate
文件夹。 当我运行App时,API请求响应下面的html文件

var ExceptionCode;
(function (ExceptionCode) {
    /**
     * API is not implemented.
     *
     * This usually means the API can't be used because it is not implemented for
     * the current platform.
     */
    ExceptionCode["Unimplemented"] = "UNIMPLEMENTED";
    /**
     * API is not available.
     *
     * This means the API can't be used right now because:
     *   - it is currently missing a prerequisite, such as network connectivity
     *   - it requires a particular platform or browser version`

API 的调用方式类似于

this.$axios.$post('/api/example')

我尝试在

this.$axios.defaults.baseURL = "https://example.com"
之前添加
this.$axios.$post('/api/example')
但没有成功。

如何像在网站上那样正确获取 API 请求?

javascript vue.js axios nuxt.js capacitor
1个回答
0
投票

你是如何解决问题的?我也有同样的问题

© www.soinside.com 2019 - 2024. All rights reserved.