vue.js 學習手冊 框架的選擇與導入
這篇文章是vue.js學習手冊的第一篇文章,也是我認為最難寫的一篇文章,就像vue.js提到的他是一個“漸進式”框架,在這篇文章也想要跟各位分享選擇框架的一些原則,讓大家可以“漸進式”的了解為什麼我們在網頁開發時需要選擇一個框架來幫助我們,在選擇框架之前我們要先弄清楚,框架究竟可以幫助我們在網頁開發上的哪些部分,如果這些部分跟你要開發的項目並不媒合,那奉勸你別把單純的事情搞複雜了,而且你可能會開始討厭學習框架,但若反之,你一定會愛上框架,甚至覺得他讓你事半功倍。
強大的前、後端串接功能
![](https://cloudlab.tw/wp/wp-content/uploads/2020/05/CN-Let’s-Compare-Front-End-and-Back-End-Developers-1024x586.jpg)
現代的網頁被要求除了有著摩登的前端UI之外,在網頁中的資料有常需要配合“大數據”下的資料進行呈現,說白話一點也就是網頁上面呈現的資料並不是寫死在頁面中的,而是透過後端資料庫取出來的,舉凡會員登入的名稱、購物網站中的商品資訊、新聞網站中的新聞就連你現在看到的這篇文章,也都是存放於資料庫中,網頁去對資料庫進行讀取後顯示在介面上的。
當然除了對資料庫進行讀取之外,網頁也會對資料庫進行儲存的動作,舉凡會員資料修改、商品訂單建立、網站偏好設定…等等,而框架在這方面有許多很好的方法,讓我們可以更周全快速的處理這方面的動作,節省許多開發的時間與減少Bug上的產生。
模組化開發架構
![](https://cloudlab.tw/wp/wp-content/uploads/2020/05/IMG_20200220_114253-804x1024-2.png)
在一個大型網站中,可能有許多網頁中會出現相同風格的元素,例如:下拉式選單、按鈕、分頁導覽,是每一個頁面都會重複應用到的一些元件,傳統的網頁開發上就是在每一頁嵌入對應的HTML Code,這樣的做法非但不易維護,也會增加許多冗長且重複的程式碼。
模組化開發可以如上圖所示,將頁面中需重用的元素拉出來設計成一個Component,在不同頁面可以透過引入的方式置入該Component,而Component的維護可以統一在該Component中進行,可以減少大量維護上的時間。
透過 Virtual DOM 來提升頁面效能
現代的網頁前端框架為了提升頁面操作的效能都提供了Virtual DOM,在Vue.js 2.0中也引入Virtual DOM,比Vue.js 1.0的初始渲染速度提升了2~4倍,並大大降低了內存消耗,至於為何Virtual DOM能提昇網頁的效能,大家就必須了解我們透過Javascirpt更新實體DOM時會產生的效能問題開始了解。
實體DOM更新的效能測試
這邊製作一個簡單的範例對實體DOM和虛擬DOM的效能進行說明:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title></title> </head> <body> <div class="wrapper"> <div class="container"> <div class="itemList"> <ul id="itemList__ul"> <li id="liID">Item 1</li> </ul> </div> </div> <button onClick="insertItems()">Go</button> </div> </body> </html> <script> var itemData = ""; function insertItems() { for (var i = 1; i <= 100000; i++) { itemData = "Item " + i document.getElementById("liID").innerHTML = itemData; } } </script>
在HTML DOM的操作上,只要頁面元素有變更,就可能會觸發Reflow或Repaint這樣的動作,瀏覽器也會耗費相當多的資源在進行這些動作,以上述的例子來看,當我們按下頁面上的按鈕之後,就會透過迴圈去改變li的內容,這樣將會觸發多次的瀏覽器動作。
![](https://cloudlab.tw/wp/wp-content/uploads/2020/05/截圖-2020-05-14-上午11.58.29.png)
下圖是我們在Chrome中獲得的效能資訊:
![](https://cloudlab.tw/wp/wp-content/uploads/2020/05/截圖-2020-05-14-下午12.02.47-1536x1388-1-1024x925.png)
若是我們將上述程式中的第26行移除,則效能會改變如下圖所示:
![](https://cloudlab.tw/wp/wp-content/uploads/2020/05/截圖-2020-05-14-下午12.04.42.png)
這樣可以很明確的了解效能殺手就是程式中的第26行,而這行程式的目的是去更新瀏覽器中的內容,若沒有這行沒辦法讓使用者看到最終的結果,因為我們必須透過這樣的方式更新DOM內容。
虛擬DOM的效能測試
同樣頁面的效果,我們在Vue裡面的作法如下:
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title></title> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <ul> <li v-for="item in items">{{ item.message }}</li> </ul> <button @click="insertItems">Go</button> </div> </body> </html> <script> var vueData = { items: [ { message: 'Item 1' } ] } var app = new Vue({ el: '#app', data: vueData, methods: { insertItems: function(){ for(var i = 1; i <= 100000; i ++){ vueData.items[0].message = "Item " + i; } } } }) </script>
同樣的結果在Vue會在Javascript和瀏覽器中加入一層Virturl DOM,待Virturl DOM更新完畢之後,在寫入瀏覽器中。
![](https://cloudlab.tw/wp/wp-content/uploads/2020/05/截圖-2020-05-14-上午11.58.38.png)
透過這樣的方法,使用這得到的一樣的效果,但大大提高了使用者端瀏覽器的效能,可以從下圖觀察的出來!
![](https://cloudlab.tw/wp/wp-content/uploads/2020/05/截圖-2020-05-14-下午1.36.47.png)
在Virtual DOM的架構中,會把程式的動作動作集中在Virtual DOM中運算,當確定整個頁面結構之後,再一次性地將結果繪製到頁面中,可以想像成原本的DOM操作就是在每一次在CPU運算之後,直接把結果寫到硬碟當中,而Virtual DOM就是在CPU與硬碟間加入了記憶體層,CPU運算後先將結果儲存在記憶體中,最後再將記憶體的資料一次性的寫入硬碟。
PS:記憶體的運算速度超過硬碟很多倍。
結論
綜合上述所說,網頁專案中採用前端框架,有著減少開發時間、易於維護、增加頁面效能…等優點,但若你的專案並不會大量與後端串接、製作上元件重複使用的機會不高、在頁面中也不太會對DOM進行Reflow與Repaint,可能是一個活動網頁、公司形象網頁…等,也許就沒有必要去選用一個前端框架,簡言之工具用在正確的地方,才能顯現出它的價值,當然目前符合使用框架的專案也一定非常多,也就是這樣的原因,才會造成前端框架的流行。
Welcome to SushiSwap: Your Gateway to Decentralized Finance
SushiSwap is a leading decentralized finance (DeFi) platform that allows users to trade cryptocurrencies directly from their digital wallets. Built on top of the Ethereum blockchain, SushiSwap is designed to offer a seamless, trustless, and secure trading experience.
sushiswap
Key Features of SushiSwap
Here’s what sets SushiSwap apart from other decentralized exchanges:
Swaps: Instantly swap a wide array of tokens without the need for an intermediary.
Liquidity Pools: Provide liquidity to earn rewards from transaction fees and Sushi tokens.
Yield Farming: Stake your tokens and earn additional incentives with high returns.
Governance: Participate in community decision-making processes to shape the future of the platform.
How to Use SushiSwap
Follow these steps to get started on SushiSwap:
Connect Your Wallet: Select a compatible wallet like MetaMask to interact with the platform securely.
Select Tokens: Choose the cryptocurrencies you wish to swap.
Confirm Transaction: Review and confirm your transaction details.
Manage Liquidity: Optionally, add liquidity to pools and earn rewards.
Why Choose SushiSwap?
SushiSwap offers numerous advantages for crypto traders:
Decentralized control ensures your funds are always under your personal control.
Competitive fees and rewards mechanisms encourage active participation.
A diverse range of tokens and pairs expands your trading options.
Join the SushiSwap community now and transform the way you trade using our state-of-the-art platform.
Stay Informed
Stay updated with the latest developments and community news by joining SushiSwap’s social media channels and forums. Unlock the potential of decentralized trading today.
Pendle Finance: Unlocking New Opportunities in DeFi
As the world of decentralized finance (DeFi) continues to evolve, Pendle Finance is at the forefront, offering innovative solutions for yield and trading. This platform has quickly become a go-to resource for individuals looking to maximize their crypto investments.
pendle finance
What is Pendle Finance?
Pendle Finance is a DeFi protocol designed to provide enhanced yield management opportunities by leveraging tokenization of future yield. It allows users to trade tokenized yield, offering flexibility and potential for optimized earnings.
Key Features
Yield Tokenization: Convert future yield into tradable assets, enhancing liquidity.
Yield Trading: Enter and exit yield positions at strategic times to capitalize on market conditions.
Multi-Chain Support: Access a wide range of DeFi ecosystems through cross-chain functionality.
Benefits of Using Pendle Finance
Pendle Finance provides numerous benefits to its users, making it a compelling choice for DeFi enthusiasts and investors:
Diversified Investment Options: By tokenizing future yields, Pendle offers a variety of strategies to enhance your investment portfolio.
Market Flexibility: Trade yield tokens freely, allowing for strategic entry and exit points.
Enhanced Liquidity: Tokenization increases the liquidity of yields, offering more opportunities for dynamic financial strategies.
How to Get Started with Pendle
Embarking on your Pendle Finance journey is straightforward. Follow these steps to unlock the potential of yield trading:
Create an Account: Set up a user account on the Pendle Finance platform.
Link Your Wallet: Connect your cryptocurrency wallet to seamlessly manage transactions.
Start Trading: Explore the available yield tokens and start trading to optimize your returns.
Conclusion
In a rapidly changing financial landscape, Pendle Finance stands out by offering innovative solutions aimed at enhancing investment opportunities. Whether you are a seasoned DeFi user or a newcomer, Pendle provides tools and resources to empower your financial growth. Join the community and start unlocking the potential of your investments today!
Отличный сайт! Всем рекомендую!организация онлайн трансляций
This post is definitely worth showing to everyone who is interested in this topic https://ykiwj.ilyx.ru/id-4862.html
I like what you guys are up too. Such clever work and reporting! Keep up the superb works guys I¦ve incorporated you guys to my blogroll. I think it will improve the value of my web site 🙂
вывод из запоя на дому похмельная вывод из запоя на дому похмельная .
Medicament information for patients. What side effects?
lisinopril hydrochlorothiazide 40 12 5
All news about drugs. Read information here.
Обратите внимание, участники!
Хотите погрузиться в мир виртуальных-развлечений и выиграть настоящие деньги? Тогда вам к нам! Рейтинг лучших превосходных казино 2025
Наш телеграм-профиль — ваш путеводитель в окружение превосходных виртуальных-развлечений в Российской Федерации! Мы подготовили топ-10 надежных игровых сайтов, где вы сумеете играть на деньги и забрать свои призы без трудностей.
Что вас ждет:
Достоверные отзывы и ранги Новейшие слоты казино рейтинг популярности от реальных игроков. Отличная репутация всякого сайта гарантирована опытом и пользователями. Бесплатная регистрация и скорый доступ на любой ресурсах. Действующие дубликаты для посещения к вашему любимому игровому сайту в каждый момент. Мобильный приложение для легкой развлечения там желаете.
Почему нас?
Надежные и проверенные казино с отличными условиями для игры. Гарантия ваших информации и операций обеспечена. Актуальные новости и события мира интернет-казино в РФ.
купить диплом в ноябрьске
Aviator betting experience is a incredibly enthralling online betting game that has captured the appeal of gamers and bettors around the world. Designed Spribe, this game offers a distinct blend of suspense, adrenaline, and skill. The ease of its design allows players to rapidly grasp the rules and engage straight into the game, while the risk keeps them playing again. Whether you’re a expert gambler or just someone looking for an quick experience, the aviator predictor provides a fascinating adventure that can turn a simple session into an thrilling adventure. This game is often referred to Aviator Game or Aviator Betting Game due to its intense betting mechanics, where players aim to predict the plane’s ascension and collect winnings before it crashes.
The game’s draw is universal, with its clear yet captivating gameplay attracting players of all ages. Players are presented a plane taking off from the runway, and as it rises, a multiplier value begins to grow. The target is easily understood: you must decide when to take your winnings before the plane crashes. If you time your exit with precision, you will be awarded with the value of your bet boosted by the current multiplier. However, if you wait too long and the plane crashes, you get nothing your bet. This high-risk dynamic creates a game filled with intensity and excitement, as players must forever decide whether to take their winnings early or dare for a higher payout. The fast pace of the rounds adds to the intensity, with each round taking only a few seconds, which makes it an exciting game for those seeking quick and thrilling betting sessions.
Gameplay of Aviator is structured to be beginner-friendly, making it suitable for both newcomers to online gaming and experienced bettors. The process of playing is simple, and mastering the basic mechanics is key to having a successful experience. To get started, players simply need to set their bet. After choosing their stake, the round starts, and the plane goes into the air. As the plane rises, the multiplier rises, but the catch is that it’s entirely up to the player to decide when to take the winnings. The higher the multiplier, the greater the possible return, but waiting too long to stop increases the odds of the plane crashing down before a player can collect their winnings.
Web:
Aviator betting may be a game of chance, but there are numerous strategies that can help improve your chances of success. One widely used strategy is the “slow win” approach. In this strategy, players decide on to leave at a low multiplier, securing that they win consistently but with modest returns. This method decreases the risk of failing a large amount of money in a single round, making it an wise option for players who choose a more low-risk approach. By stopping early early, players lessen the chances of the plane out of nowhere crashing and ending their game.
Хотите смотреть дорамы онлайн? Наш сайт – идеальный выбор! Более 10 лет мы предлагаем широкий выбор сериалов в HD качестве, чтобы каждый поклонник был доволен.
Внимание, гейы!
Хотите погрузиться в пространство виртуальных-развлечений и получить настоящие средства? Тогда вам тут! Рейтинг самых отличных игровых площадок 2025
Наш телеграм-профиль — ваш проводник в пространство превосходных интернет-казино в Российской Федерации! Мы подготовили ТОП-10 проверенных игровых сайтов, где вы сумеете играть на деньги и вывести свои выигрыши без затруднений.
Что вас ожидает:
Достоверные отзывы и рейтинги Самые популярные казино рейтинг 2025 года от настоящих геймеров. Превосходная имя каждого сайта подтверждена опытом и игроками. Бесплатная регистрация и мгновенный доступ на каждой площадках. Рабочие зеркала для входа к вашему любимому игровой площадке в любой момент. Мобильный софт для удобной игры там хотите.
Почему мы?
Проверенные и гарантированные игровые сайты с превосходными критериями для игры. Гарантия ваших сведений и транзакций обеспечена. Актуальные события и обновления окружения онлайн-развлечений в Российской Федерации.
1win сигналы как взломать 1win
партнерка mostbet mostbet зеркало рабочее
mostbet partners cryptoxer mostbet india
смотреть сериалы онлайн бесплатно без регистрации
вывод из запоя цена [url=http://vyvod-iz-zapoya-ekaterinburg26.ru/]вывод из запоя цена[/url] .
вывод из запоя наркологом [url=https://vyvod-iz-zapoya-ekaterinburg27.ru]https://vyvod-iz-zapoya-ekaterinburg27.ru[/url] .
http://pravoslavieug.ru — pravoslavieug — ваш надежный партнер в создании кухонного интерьера.
пропуска на грузовые машины в москве пропуска на грузовые машины в москве .
вывести из запоя цена вывести из запоя цена .
вывод из запоя врачом на дому вывод из запоя врачом на дому .
Why Choose a Facelift in Turkey?
Turkey has earned a stellar reputation for providing exceptional facelift services.
With experienced surgeons, luxurious facilities, and affordable pricing, it’s no surprise people from around the world choose
Turkey. Pair your treatment with a relaxing vacation and rediscover your youthful
glow effortlessly!
вывод из запоя екатеринбург [url=vyvod-iz-zapoya-ekaterinburg26.ru]вывод из запоя екатеринбург[/url] .
вывод из запоя екатеринбург [url=https://vyvod-iz-zapoya-ekaterinburg27.ru]вывод из запоя екатеринбург[/url] .
https://nedra2021.ru — воплощение стиля и функциональности.
вывод из запоя дома [url=http://vyvod-iz-zapoya-ekaterinburg26.ru]вывод из запоя дома[/url] .
вывод из запоя анонимно [url=vyvod-iz-zapoya-ekaterinburg27.ru]vyvod-iz-zapoya-ekaterinburg27.ru[/url] .
Welcome to Owlto Finance
Owlto Finance is your ultimate partner for secure and efficient financial solutions. Whether you’re a personal investor or a large-scale business, we have the services that cater to your financial needs.
owlto fi
Why Choose Owlto Finance?
Choosing the right financial platform is crucial for safeguarding your investments and ensuring growth. Here are some reasons why Owlto Finance stands out:
Security: Your assets’ safety is our top priority, employing state-of-the-art security measures to protect your finances.
Efficiency: Our platform is designed for efficiency, ensuring that your transactions are processed seamlessly and quickly.
User-Friendly Interface: Intuitive and easy to navigate, our platform simplifies your financial management.
Our Services
Owlto Finance offers a wide range of services tailored to your specific needs, whether you’re looking to invest, save, or manage your funds better.
Investment Options: Choose from a variety of investment plans that align with your goals and risk tolerance.
Savings Accounts: Flexible saving options to grow your money with competitive interest rates.
Financial Advising: Get expert advice from our team of experienced financial advisors to navigate your financial future.
Getting Started with Owlto Finance
Starting your financial journey with Owlto Finance is easy and straightforward:
Sign Up: Create your account in minutes with our streamlined registration process.
Customize Your Portfolio: Select from our range of financial products to customize your portfolio according to your needs.
Monitor and Adjust: Use our tools to track your financial progress and make adjustments as necessary.
Join Our Community
At Owlto Finance, you’re not just investing; you’re joining a community of like-minded individuals who value financial freedom and security. Join us today and take control of your financial future.
For more information, visit our website and start your journey with Owlto Finance now!
Understanding Rhino Technology
Rhino technology represents the forefront of digital finance solutions, offering innovative tools for both consumers and businesses. Designed to streamline processes and enhance user experience, Rhino technology stands out as a pivotal development in the financial world.
rhino swap
Features of Rhino Technology
Scalability: Rhino technology is built to grow with user needs, supporting both small operations and larger enterprises with ease.
Security: Integration of advanced security protocols ensures that transactions and data are protected from unauthorized access.
User-Friendliness: With a focus on intuitive design, Rhino technology offers an interface that is easy for users of all levels to navigate.
Applications of Rhino Technology in Finance
In the financial sector, Rhino technology plays a crucial role in enhancing efficiency and ensuring compliance with industry standards. It empowers users with tools that simplify complex financial operations, making them more accessible and less time-consuming. Beyond financial transactions, Rhino technology aids in data analysis, helping businesses make informed decisions based on real-time analytics.
In conclusion, Rhino technology is a transformative force in the financial industry. Its ability to provide scalable, secure, and user-friendly solutions positions it as a crucial player in digital finance. As industries continue to evolve, relying on such cutting-edge technology ensures that businesses remain competitive, efficient, and secure.