ModernWeb
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    6
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Vue.js: The bad parts. / Kuro Hsu(許國政) {%hackmd @ModernWeb/HkqZxb98v %} ### [大神#Kuro Hsu簡報支援](https://s.itho.me/modernweb/2020/Slides/d204.pdf) >共筆從這開始 ### 混亂的模板與語法 * 到處都是 this * 我能用 arrow function 嗎? * 是不是使用Vue.js 就不能享受最新的ES6語法? * 組件必須是單一根節點 即使用兩個組件包起來,vue還是會偷偷多生一個div出來 * Component的事件管理 * v-on:事件名稱 * $on(事件名稱) * 事件來源難以掌控 * Async Hooks? 不好意思・你得自己包Promise ### 狀態管理與畫面的「不」同步:Reactivity * MVVM 框架 * 物件狀態越複雜,花費的成本越高(set) * 狀態更新時,無需跑迴圈逐一檢查,先前複寫的 set 會主動通知 * 物件狀態越複雜,成本越高 * 最大的問題是... * Object.defineProperty() 的先天限制 * 直接修改 data 某個陣列內容 * 直接刪除某個 data 內的物件屬性 * 直接新增某個 data 內的物件屬性 * 以上 Object.defineProperty() 都**追蹤不到** * 必須使用 vue.$set() 強制寫入更新 ### 糟糕的效能 解方 * Render function * functional (stateless) component * `functional: true` * `<template functional>` * 透過Object.freeze鎖定 data * [一般 component vs functional component 比較](https://kuro.tw/vue-functional-demo/index.html) ### 邏輯與程式碼難以管理、複用 * 邏輯與程式碼的複用 * extends * mixins * Mixins的困境 * 狀態來源不明確 * 各種Method命名衝突:在不同Mixins會有同樣名稱的可能 * 當專案規模擴大,複雜度增加重構難度 # [Vue 3.0](https://github.com/vuejs/vue-next/releases/tag/v3.0.0) ### 混亂的模板與語法? * 改由createApp建立實體,不再有全域污染的問題 * ~~組件必須是單一根節點~~ * Vue 3.0 的 Fragments 特性打破了過去的 * 父子組件間的狀態傳遞 * 同樣是 props in, event out. * Vue 3.0 新増 ```<component>``` with v-model ### Reactivity in Vue 3 * Change Detection Caveats * Object.defineProperty() ➡ Proxy API * 沒有 Vue 2.x 提到的那些問題 * 唯一缺點是 IE 11 不支援 * 整體來說 Z > B ### 模板編譯:靜態節點優化 * 模板內容改由動態指令 ( v-if / v-for / slot) 來切分為獨立的區塊 * 每個動態的節點內容、位置是固定的 * Virtual DOM 更新時只需要遍歷動態的節點,更新效率與實際 DOM 數量脫鉤,減少不必要的效能浪費 * 與 Vue 2.x 效能相比**可提升 2-5 倍** ### Functional Component in Vue 3 * Render function * ~~functional (stateless) component~~ * ~~functional: true~~ * ~~```<template functional>```~~ ### 混亂的模板與語法? * Component 的事件管理 * ~~$on(事件名稱)~~ * v-on:事件名稱 * Vue 自 3.0 起取消了 $on / $once / $off * *組件資料 / 狀態的管理* * *this 與 箭頭函式* * *程式碼與邏輯的管理與複用* -> **共同解藥: Compositions API** ### Compositions API * 並非為了取代現有的 Options style * 為了解决大型應用的痛點(狀態、邏輯管理、複用) * 狀態來源清晰・無namespace的衝突 * 沒有「this」 * 開發彈性大,效能佳 * 易於切分管理語法類似React Hooks. > https://composition-api.vuejs.org/ # Vue.js v.s. Vue.js 3.0 | Vue.js: The Bad Parts ? | Vue.js 3.0:The Good Parts! | | -------- | -------- | | 狀態管理與畫面的「不」同步 | 清晰的模板與語法 | | 糟糕的效能 | 狀態與畫面不再各說各話 | | 混亂的模板與語法 | 更小的檔案、更快的效能 | | 邏輯與程式碼難以管理、複用 | 邏輯、程式碼的管理複用更方便 | ### Vue.js生態圈 * Vite * Vuejs 2.7 (LTS version / 2021 Q1) * Vue Developer Experience (@vuedx) * next ...? Vue's Mission: Be a framework that grows with the user ###### tags: `MW20` `框架與應用` `Vue.js`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully