文章加密

;

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