会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
aisowe
上一页
1
2
3
4
5
6
7
8
···
13
下一页
2021年9月9日
Git 查看文件修改详情
摘要: 查看仓库当前状态 git-bash git diff
阅读全文
posted @ 2021-09-09 10:29 aisowe
阅读(457)
评论(0)
推荐(0)
Git 查看历史提交记录
摘要: 查看历史提交记录 git-bash git log 如果觉得比较凌乱,可以用简略版:git log --pretty=oneline
阅读全文
posted @ 2021-09-09 10:28 aisowe
阅读(495)
评论(0)
推荐(0)
查看某个 npm 包当前最新发行版本的相关信息,比如 vuex
摘要: bash npm view vuex # or npm info vuex
阅读全文
posted @ 2021-09-09 10:28 aisowe
阅读(262)
评论(0)
推荐(0)
Git 查看版本切换记录
摘要: 查看历史提交记录 git-bash git reflog 常配合git reset --hard用于回到未来的某个分支。
阅读全文
posted @ 2021-09-09 10:27 aisowe
阅读(218)
评论(0)
推荐(0)
js 往dom元素中插入类名
摘要: index.js const img = document.createElement('img') // const img = new Image() img.classList.add('avatar')
阅读全文
posted @ 2021-09-09 10:26 aisowe
阅读(315)
评论(0)
推荐(0)
查看 ECMAScript 内置对象类型清单和声明文件源码
摘要: browser https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects https://github.com/Microsoft/TypeScript/tree/master/src/lib
阅读全文
posted @ 2021-09-09 10:26 aisowe
阅读(67)
评论(0)
推荐(0)
ts 中表现元组越界后的行为
摘要: index.ts const lilei: [string, number] = ["Lilei", 23]; lilei.push(NaN); // 3 lilei.push("NaN"); // NaN lilei.push(true); // string | number -> Error
阅读全文
posted @ 2021-09-09 10:25 aisowe
阅读(205)
评论(0)
推荐(0)
不用 devServer 就实现文件发生变动时就重新打包
摘要: webpack.config.js module.exports = { entry: { main: './src/index.js', }, } package.json { "scripts": { "watch": "webpack --watch" }, }
阅读全文
posted @ 2021-09-09 10:25 aisowe
阅读(32)
评论(0)
推荐(0)
TypeScript class 便捷设置实例属性
摘要: index.ts class Foo { constructor(public name: string, public readonly age: number) {} } const foo = new Foo("foo", 23); console.log(foo.name); console
阅读全文
posted @ 2021-09-09 10:24 aisowe
阅读(164)
评论(0)
推荐(0)
React 避免 setState 的合并调用特性
摘要: index.js import React from 'react' import ReactDOM from 'react-dom' class ANumber extends React.Component { constructor() { super() this.state = { num
阅读全文
posted @ 2021-09-09 10:23 aisowe
阅读(252)
评论(0)
推荐(0)
编写一个基本通用的 tsconfig.json 配置文件
摘要: tsconfig.json { "compilerOptions": { "target": "ESNEXT", "lib": ["DOM", "ESNEXT"], "module": "commonjs", "sourceMap": true, "outDir": "./dist", "modul
阅读全文
posted @ 2021-09-09 10:23 aisowe
阅读(111)
评论(0)
推荐(0)
React 绑定事件监听函数
摘要: index.js import React from 'react' import ReactDOM from 'react-dom' class Btn extends React.Component { render() { return <button onClick={() => alert
阅读全文
posted @ 2021-09-09 10:22 aisowe
阅读(499)
评论(0)
推荐(0)
保留 a 标签链接样式的同时,让页面不发生跳转
摘要: index.html <a href="javascript:void(0)" onclick="alert('右究')">点击</a>
阅读全文
posted @ 2021-09-09 10:22 aisowe
阅读(33)
评论(0)
推荐(0)
按条件从左往右移除数组中的元素
摘要: index.ts import * as _ from 'lodash' const list = [ { name: 'a', gender: 1 }, { name: 'b', gender: 0 }, { name: 'c', gender: 1 }, { name: 'd', gender:
阅读全文
posted @ 2021-09-09 10:21 aisowe
阅读(54)
评论(0)
推荐(0)
按条件从右往左移除数组中的元素
摘要: index.ts import * as _ from 'lodash' const list = [ { name: 'a', gender: 1 }, { name: 'b', gender: 0 }, { name: 'c', gender: 1 }, { name: 'd', gender:
阅读全文
posted @ 2021-09-09 10:20 aisowe
阅读(52)
评论(0)
推荐(0)
安装、注册 Vuex
摘要: npm npm i -S vuex main.js import Vue from 'vue' import Vuex from 'vuex' import App from './App.vue' Vue.use(Vuex) new Vue({ store: new Vuex.Store({ /*
阅读全文
posted @ 2021-09-09 10:19 aisowe
阅读(75)
评论(0)
推荐(0)
安装特定版本的 npm 包
摘要: bash npm i -D webpack@4 # npm i -D webpack@4.x.x
阅读全文
posted @ 2021-09-09 10:19 aisowe
阅读(308)
评论(0)
推荐(0)
安装 lodash
摘要: npm npm i -S lodash npm i -D @types/lodash
阅读全文
posted @ 2021-09-09 10:17 aisowe
阅读(357)
评论(0)
推荐(0)
怎样在 Vue3 中使用 defineComponent 和 ref 实现一个计数器组件
摘要: Counter.vue <template> <button @click="increment">{{ count }}</button> </template> <script lang="ts"> import { defineComponent, ref } from "vue"; expo
阅读全文
posted @ 2021-09-09 10:15 aisowe
阅读(1350)
评论(0)
推荐(0)
怎样在 Vue3 中使用 reactive 实现一个计数器组件
摘要: Counter.vue <template> <button @click="increment">{{ count }}</button> </template> <script lang="ts"> import { reactive, toRefs } from "vue"; export d
阅读全文
posted @ 2021-09-09 10:15 aisowe
阅读(123)
评论(0)
推荐(0)
怎样用一个 sleep 函数演示 async、await 的用法
摘要: index.js function sleep(n = 0) { return new Promise((resolve) => { setTimeout(function () { resolve(); }, n); }); } async function clock() { while (tr
阅读全文
posted @ 2021-09-09 10:14 aisowe
阅读(94)
评论(0)
推荐(0)
怎样用原生 Koa 实现路由功能
摘要: index.js const Koa = require("koa"); const app = new Koa(); app.use((ctx) => { switch (ctx.url) { case "/": ctx.body = "<h1>index.html</h1>"; break; d
阅读全文
posted @ 2021-09-09 10:14 aisowe
阅读(37)
评论(0)
推荐(0)
怎样用 koa-router 实现 get 请求
摘要: index.js const Koa = require("koa"); const Router = require("koa-router"); const app = new Koa(); const router = new Router(); router.get("/", (ctx) =
阅读全文
posted @ 2021-09-09 10:13 aisowe
阅读(39)
评论(0)
推荐(0)
怎样用 koa-bodyparser 获取 POST 请求上下文中的表单数据
摘要: index.js const Koa = require("koa"); const bodyParser = require("koa-bodyparser"); const app = new Koa(); app.use(bodyParser()); app.use(async (ctx) =
阅读全文
posted @ 2021-09-09 10:12 aisowe
阅读(88)
评论(0)
推荐(0)
怎样用 Koa 搭配 fs 模块返回一个 html 文件给前端
摘要: index.js const fs = require("fs"); const Koa = require("koa"); const app = new Koa(); app.use(async (ctx) => { const html = fs.readFileSync("./index.h
阅读全文
posted @ 2021-09-09 10:11 aisowe
阅读(747)
评论(0)
推荐(0)
怎样用 koa 解析出 POST 请求上下文中的表单数据
摘要: index.js const Koa = require("koa"); const app = new Koa(); function bodyParser(ctx) { return new Promise((resolve, reject) => { let postData = ""; tr
阅读全文
posted @ 2021-09-09 10:11 aisowe
阅读(165)
评论(0)
推荐(0)
怎样用 Koa 写 Hello, World!
摘要: index.js const Koa = require("koa"); const app = new Koa(); app.use((ctx) => { ctx.body = "Hello, World!"; }); app.listen(3000);
阅读全文
posted @ 2021-09-09 10:11 aisowe
阅读(33)
评论(0)
推荐(0)
怎样使用 Vue-CLI 创建 Vue3 项目
摘要: 首先,需要安装 Vue-CLI,版本大于 4.5.4,然后使用 vue create <project-name>初始化项目; 然后,项目初始化使用选项3:Manually select features,选择这几项,然后回车: Vue CLI v5.0.0-beta.0 ? Please pick
阅读全文
posted @ 2021-09-09 10:10 aisowe
阅读(338)
评论(0)
推荐(0)
Koa 中怎样获取请求中的 query 参数
摘要: index.js const Koa = require("koa"); const app = new Koa(); app.use((ctx) => { const { request: { query: query1, querystring: queryString1 }, query, q
阅读全文
posted @ 2021-09-09 10:09 aisowe
阅读(442)
评论(0)
推荐(0)
怎样开发一个最简版 Koa 日志打印中间件
摘要: index.js const Koa = require("koa"); const app = new Koa(); /** * a simple log middleware * @param {object} ctx */ function logger() { return async fu
阅读全文
posted @ 2021-09-09 10:09 aisowe
阅读(100)
评论(0)
推荐(0)
怎样安装 Koa
摘要: npm i -S koa
阅读全文
posted @ 2021-09-09 10:08 aisowe
阅读(22)
评论(0)
推荐(0)
辅助理解 this 的一些代码片段
摘要: 构造函数式实例化对象、数组和函数 typeof new Object() 'object' // true Array.isArray(new Array()) // true typeof new Function() 'function' // true 字面量写法实例化对象、数组和函数 typ
阅读全文
posted @ 2021-09-09 10:02 aisowe
阅读(37)
评论(0)
推荐(0)
历史随笔: Array 的一些基础属性方法
摘要: 数组对象: Array 1. 前言 数组也好, 列表也好, 在不同的编程语言里面叫法虽然不一样, 但其本质是一样的, 作为最常用的对象, 其属性和方法是必须要牢记在心的, 以下是Array对象的完整属性方法示例. 2. 参数 情况1: 没参数 var arr = new Array(); // 实例
阅读全文
posted @ 2021-09-09 09:47 aisowe
阅读(71)
评论(0)
推荐(0)
68行代码实现贪吃蛇(Canvas)
摘要: <canvas id="gc" width="400" height="400"></canvas> <script> window.onload=function() { canv = document.getElementById("gc"); ctx = canv.getContext("2d
阅读全文
posted @ 2021-09-09 09:45 aisowe
阅读(64)
评论(0)
推荐(0)
怎样在 Svelte 中将 store 绑定到表单组件
摘要: 正文 所谓表单组件就是跟用户有交互的、能取到值的、是 form 的表单项的组件。在 Vue、React 中,store 里面的数据是严格控制其变动方式的,store 中的 state 只能通过 commit 触发改变。而 Svelte 中的 store 的更新是“自带”的,通过 set、update
阅读全文
posted @ 2021-09-09 09:42 aisowe
阅读(101)
评论(0)
推荐(0)
怎样在 Svelte 中使用 getters: derived
摘要: 正文 Svelte 中的 store 不仅有 state,也可以有 getters,不过名字叫:derived,不太好读,但英文意思很直观:衍生的,也就是说,经他生成的数据是由其他 state 衍生的,这其实就是 getters 的定义,而 getters 也可以理解成 store 中的计算属性,也
阅读全文
posted @ 2021-09-09 09:41 aisowe
阅读(197)
评论(0)
推荐(0)
怎样在 Svelte 中自定义 store
摘要: 正文 我们拿一个计数器举例,count 变量存在 store 中,我们用 count.set() 重置,用 count.subscribe() 订阅,用 count.update() 更新,一切看起来都很 OK,但实际上,如果想要更好的可维护性,这个 count 应该继续定义它的行为逻辑,也就是预定
阅读全文
posted @ 2021-09-09 09:41 aisowe
阅读(88)
评论(0)
推荐(0)
怎样在 svelte/store 中进行状态自动订阅
摘要: 正文 下面代码中手动订阅与取消订阅的代码其实非常冗余,Svelte 提供了自动订阅的功能,可以自动为我们做订阅和取消订阅的操作。 <script> import { writable } from 'svelte/store' import {onDestroy} from 'svelte' con
阅读全文
posted @ 2021-09-09 09:40 aisowe
阅读(80)
评论(0)
推荐(0)
怎样使用 svelte/store 中的 readable
摘要: 正文 存在某些 store-state,它们的变动来源只依赖一个地方,且跟项目业务逻辑无关,这时其他地方都不会去修改它。比如获取当前时间,这时就不需要在特定组件里面去做修改,而是直接在设定 time 的时候,就将变动规则传给他,然后它就自己在那儿触发就行了,不需要管它。 <script> impor
阅读全文
posted @ 2021-09-09 09:40 aisowe
阅读(65)
评论(0)
推荐(0)
Svelte 中状态管理(store)的简单用法
摘要: 正文 以简单计数器为例,计数变量放在 store-state 中,它使用 svelte/store 中的 writable 方法,它会返回一个对象,通过调用对象上的 .set(val) 进行重置、调用 .update((val) => ...) 进行更新、调用 .subscribe(val => .
阅读全文
posted @ 2021-09-09 09:39 aisowe
阅读(501)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
···
13
下一页
公告
导航
博客园
首页
新随笔
联系
订阅
管理