文章加密

;

2020年6月26日 星期五

PhoneGap

https://phonegap.com/  官網

PhoneGap 為一個跨平台的免費框架,程式設計師只要設計好一種版本的網頁標準格式 (HTML5、JavaScript、CSS) 之後,就能透過 phoneGap 發佈到各個平台上 (Andriod, iOS, Symbian 等),而且能夠操作各種 Mobile OS 的裝置,例如照相機、GPS 等等,算是一個節省開發時間的好工具,以下是它的介紹。

2020年6月19日 星期五

arrow function

https://pjchender.blogspot.com/2017/01/es6-arrow-function.html

https://medium.com/better-programming/difference-between-regular-functions-and-arrow-functions-f65639aba256 medium熱門話題

curry 柯里化

https://cythilya.github.io/2017/02/27/currying-in-javascript/

https://jigsawye.gitbooks.io/mostly-adequate-guide/ch4.html

閉包(越往下滑,內容越好看)

https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Closures

call apply bind

https://medium.com/schaoss-blog/%E4%B8%80%E6%AC%A1%E6%90%9E%E6%87%82%E5%89%8D%E7%AB%AF%E9%9D%A2%E8%A9%A6%E6%9C%80%E6%84%9B%E5%95%8F%E7%9A%84-apply-bind-call-708f57518776

https://medium.com/@realdennis/javascript-%E8%81%8A%E8%81%8Acall-apply-bind%E7%9A%84%E5%B7%AE%E7%95%B0%E8%88%87%E7%9B%B8%E4%BC%BC%E4%B9%8B%E8%99%95-2f82a4b4dd66

https://ui.dev/this-keyword-call-apply-bind-javascript/

error(), nuxt

error: 
https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Error

nuxt's error 強制調用:
    this.$nuxt.error({ statusCode: 404, message: "hi" })


nuxt's server error (maybe about ssr):
    https://blog.lichter.io/posts/nuxtjs-change-server-error-page/

error handling時機:
    https://medium.com/@benrichardson_5275/handling-errors-while-server-side-rendering-your-code-in-nuxt-js-d733ed76239d


public async asyncData (context: any): Promise<any> {
const { params, query, route } = context;
const websiteCode = getWebsiteCode(params.region);
try {
throw new Error("hj");
} catch (e) {
console.log(e.name); // 'MyError'
console.log(e.message); // 'custom message'
context.error(e)
}

    // ...

async await promise

https://www.oxxostudio.tw/articles/201908/js-async-await.html

2020年6月17日 星期三

Vue 组件 data 为什么必须是函数?


对于这个问题很多小伙伴都问过。其实官方也有自己的说法,下面这个是官方的解答:
当一个组件被定义, data 必须声明为返回一个初始数据对象的函数,因为组件可能被用来创建多个实例。如果 data 仍然是一个纯粹的对象,则所有的实例将共享引用同一个数据对象!通过提供 data 函数,每次创建一个新实例后,我们能够调用 data 函数,从而返回初始数据的一个全新副本数据对象。
————————————————
版权声明:本文为CSDN博主「愚蠢地人类」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/shaleilei/java/article/details/78084171

https://juejin.im/entry/59225ff8a22b9d005885cb15

shallow copy vs deep copy

https://medium.com/@nickhuang_1199/%E6%B7%B1%E5%BA%A6%E4%BA%86%E8%A7%A3%E5%9C%A8javascript%E4%B8%AD%E6%B7%BA%E6%8B%B7%E8%B2%9D-shallow-copy-vs-%E6%B7%B1%E5%BA%A6%E6%8B%B7%E8%B2%9D-deep-copy-%E5%BE%97%E9%83%A8%E5%88%86-33fe501871e

類似by value v.s. by reference的概念,專指在複製行為上

2020年6月16日 星期二

小白也能看懂的Vuex 又 Vuex is different from store,使用带有 setter 的双向绑定计算属性應用到表單

https://zhuanlan.zhihu.com/p/80716895

Vuex is different from store:
應該說store是個變數,常用來存vuex整個寫好程式的,非vuex這個模組,而vuex本身其實不含那些我們添加的states, actions, ... 

https://juejin.im/post/5d1f0947f265da1b667bfb41  State, mapState, ...mapState

https://vuex.vuejs.org/zh/guide/modules.html vuex的modules概念, action的參數怎麼會變,第一個是state還是dispatch...看不懂

https://vuex.vuejs.org/zh/guide/forms.html
假设这里的 obj 是在计算属性中返回的一个属于 Vuex store 的对象,在用户输入时,v-model 会试图直接修改 obj.message。在严格模式中,由于这个修改不是在 mutation 函数中执行的, 这里会抛出一个错误。

較好的方法是使用带有 setter 的双向绑定计算属性,如下:

<input v-model="message">

//....
computed: {
  message: {
    get () {
      return this.$store.state.obj.message
    },
    set (value) {
      this.$store.commit('updateMessage', value)
    }
  }

}






2020年6月2日 星期二

deploy GitPage, add remote, change remote

https://cli.vuejs.org/guide/deployment.html#pwa (手動佈署)
手動佈署:

  1. 先在vue.config.js裡加上下列程式
  2. module.exports = {
  3.   publicPath: process.env.NODE_ENV === 'production'
  4.     ? '/my-project/'
  5.     : '/'
  6. }

  7. 執行build之後,把要呈現的檔案放上gh-pages分支


自動佈署:
  1. 建立gh-pages分支,把打包好的檔案放入
  2. If you are using Vue CLI along with a backend framework that handles static assets as part of its deployment, all you need to do is make sure Vue CLI generates the built files in the correct location, and then follow the deployment instruction of your backend framework.

    If you are developing your frontend app separately from your backend - i.e. your backend exposes an API for your frontend to talk to, then your frontend is essentially a purely static app. You can deploy the built content in the dist directory to any static file server, but make sure to set the correct publicPath.

    需要做幾個步驟,見下面網址
  3. https://cli.vuejs.org/guide/deployment.html#github-pages


$ git remote add origin https://github.com/user/repo.git
# Set a new remote
$ git remote set-url origin https://github.com/user/repo.git
# Set a change remote

Digitalocean vs AWS

https://www.guru99.com/digitalocean-vs-aws.html