提前谢谢大家。
所以,我试图找到一个解决方案(谷歌搜索,没有找到任何东西)来流下载。我的意思是,我正在将数据导出到 csv 文件,但有时数据可能大到 7MB,这对于我的后端和用户来说都很重。
我正在用 Vue 编写我们的后端是用 PHP 编写的(Yii 1.1)
这就是我目前下载文件的方式
exportCsv() {
this.loading = true;
let payload = this.csvPayload; /// computed property
this.$http
.post("/statistics/apiurl", payload)
.then(response => {
this.loading = false;
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'excelFile.csv'); //or any other extension
document.body.appendChild(link);
link.click();
})
.catch(error => {
this.loading = false;
this.campaignsLoading = false;
console.log("Problem fetching csv file: ", error.message);
});
},
Run Code Online (Sandbox Code Playgroud)
这很棒!但同样,如果文件真的很大,那么后端和用户的负担就会很重。
就像我说的,有没有办法流式下载文件?或者,我想我可以在不同的文件中创建一个可观察的对象来监听数据,一旦完成传输,就会向我的 vue 组件发送回回调......
我就是无法休息。在我当前的设置中,我可以使用 @ 别名导入文件,但我无法在 .vue 的任何内容上单击 +cmd 来“转到定义”,除非我不使用“@”别名 - 没有它适用的别名.vue 文件我还突然丢失了 node_modules 包上的所有智能感知/导入/识别(即使我从 JSConfig 中删除了包含/排除)。
如果我评论/删除我的 JSConfig,我的 nodemodules intellisense 返回,但我无法在 .js 和 .vue 文件上单击 +cmd 来“转到定义”
所以无论我做什么我都无法让它发挥作用
我的预期结果是
我在这上面花了太多时间。我完全迷路了
以下是我的规格
jsconfig.json
{
"compilerOptions": {
"target": "ES6",
"paths": {
"@/*": ["src/*"]
}
},
"exclude": ["dist", "node_modules"],
"include": ["src/**/*", "src/**/*.js", "src/**/*.vue"]
}
Run Code Online (Sandbox Code Playgroud)
vite.config.js
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
// https://vitejs.dev/config/
/// <reference …Run Code Online (Sandbox Code Playgroud) 在使用 PHPStorm/Webstorm 多年后,刚刚再次开始使用 Visual Studio 代码
我决定进行过渡,只是因为 VSCode 非常轻量级,而且我不想依赖付费服务/在每台计算机上都拥有它,因为 VSCode 几乎无处不在并且免费。
我重新开始
维特+Vue3
现在我遇到了导入 CTRL+单击的几个问题 - 转到参考自动完成
我的 Vite.config 如下 - 启用别名
import { defineConfig } from "vite";
import { fileURLToPath, URL } from "url";
import vue from "@vitejs/plugin-vue";
import path from "path";
// https://vitejs.dev/config/
/// <reference types="vitest" />
export default defineConfig({
resolve: {
extensions: [".js", ".json", ".vue", ".scss", ".css"],
fallback: {
crypto: path.resolve("crypto-browserify"),
stream: path.resolve("stream-browserify"),
},
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
img: path.resolve(__dirname, "./public/img"),
},
},
plugins: [vue()], …Run Code Online (Sandbox Code Playgroud) 我在理解 Mongoose 的概念时遇到了困难。
我正在使用 MongoDB atlas,有一个集群、一个数据库和 2 个集合。
用户、角色。
通过指南,我了解到编写内容的一个好方法是将模型(我使用命名模式)作为文件,将其导入到数据库模块/类中
并用它来执行查询...
const mongoose = require("mongoose");
const process = require("./config.env");
db = () => {
return mongoose
.connect(process.env.URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: true,
})
.then((response) => {
console.log(`Connected to Databse : ${response.connection.host}`);
})
.catch((err) => {
console.log("DB_ERROR:", err);
process.exit(1);
});
};
module.exports = db;
Run Code Online (Sandbox Code Playgroud)
const mongoose = require("mongoose");
const UserSchema = new mongoose.Schema({
username: {
type: String,
required: true,
},
password: {
type: String,
required: true,
},
email: { …Run Code Online (Sandbox Code Playgroud)