在我的组件中,我声明了一些这样的数据:
data() {
return {
defaultValue: {json object with some structure},
activeValue: {}
...
Run Code Online (Sandbox Code Playgroud)
在组件方法中,make 复制此值:
this.activeValue = this.defaultValue
Run Code Online (Sandbox Code Playgroud)
但问题是,在更改this.activeValue值之后,a 也发生了变化this.defaultValue。
如果我使用Object.freeze(this.defaultValue)并尝试更改,this.activeValue则会出现错误 - 对象不可写。
我如何复制数据但没有参考?
我正在尝试通过运行 npm script
将我的 typescript 服务器端文件(使用 tsc-watch)编译到输出目录。但是,我不断遇到以下错误:dist"watch": "tsc-watch --esModuleInterop ./src/server.ts --outDir ./dist --onSuccess 'node ./dist/server.js'"
error TS6054: File 'dist/server.js'' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
Run Code Online (Sandbox Code Playgroud)
该tsconfig.json文件如下所示:
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "es2020", /* Specify module code generation: …Run Code Online (Sandbox Code Playgroud) 我正在尝试向此端点发送请求:https://9gag.com/v1/group-posts/group/default/type/trending获取 9gag 帖子数据。
在邮递员和 chrome 上运行良好,但是当我尝试axios从 Node.js使用时,它响应403(并读取返回的 DOM,它认为它要求我输入验证码),当我尝试使用 发送请求时node-fetch,它响应与200帖子数据(这是正确的)。
问题是,为什么node-fetch工作正常但axios没有?
这是我用于测试的代码:
import axios from "axios";
import fetch from "node-fetch";
const URL = "https://9gag.com/v1/group-posts/group/default/type/trending";
// Inside async function
await fetch(URL); // Responded with 200 and json data
await axios(URL); // Responded with 403 and HTML DOM, axios.get() also gives the same result
Run Code Online (Sandbox Code Playgroud) 在 Vuejs 中,在遵循 Vuelidate 安装说明 ( https://vuelidate.js.org/#getting-started ) 时,我收到警告:
import Vuelidate from 'vuelidate'
警告说:
找不到模块“vuelidate”的声明文件。'c:/Users/[myUser]/../../index.js' 隐式具有 'any' 类型。尝试它是否存在或添加包含ts(7016)
npm install @types/vuelidate的新声明 (.d.ts) 文件declare module 'vuelidate';
javascript ×2
typescript ×2
vue.js ×2
axios ×1
copy ×1
fetch-api ×1
json ×1
node-fetch ×1
node.js ×1
reference ×1