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,可能是一個活動網頁、公司形象網頁…等,也許就沒有必要去選用一個前端框架,簡言之工具用在正確的地方,才能顯現出它的價值,當然目前符合使用框架的專案也一定非常多,也就是這樣的原因,才會造成前端框架的流行。
вывод из запоя врачом на дому вывод из запоя врачом на дому .
вывод из запоя цена вывод из запоя цена .
вывод из запоя на дому похмельная вывод из запоя на дому похмельная .
вывод из запоя цена вывод из запоя цена .
выведение из запоя на дому в екатеринбурге [url=http://vyvod-iz-zapoya-ekaterinburg25.ru]выведение из запоя на дому в екатеринбурге[/url] .
Medicine information. Effects of Drug Abuse.
where to buy linezolid without a prescription
Actual news about medicament. Read now.
https://sweetbonanza25.com/# sweet bonanza demo oyna
вывод из запоя в екатеринбурге вывод из запоя в екатеринбурге .
вывести из запоя цена вывести из запоя цена .
вывод из запоя капельница вывод из запоя капельница .
Welcome to dYdX: The Future of Decentralized Trading
dYdX is a leading decentralized exchange (DEX) platform designed specifically for perpetual trading. Powered by a unique layer 2 solution, it offers zero gas fees and high-speed transactions, ideal for traders looking to maximize efficiency and minimize costs.
dydx
Why Choose dYdX?
Fully Decentralized: Enjoy complete control over your funds and trades with no third-party intervention.
No Gas Fees: Thanks to our layer 2 integration, trade without worrying about expensive gas fees.
Advanced Features: Utilize advanced trading features like cross-margining and isolated margin accounts to optimize your strategies.
Getting Started with dYdX
To start trading on dYdX, simply connect your wallet and begin trading a wide range of perpetual contracts. Our ensures that both novice and experienced traders can navigate and execute trades with ease.
Trade Perpetual Contracts with Confidence
Perpetual contracts are a powerful trading tool that allows you to speculate on the future price movements of a variety of cryptocurrencies without owning the underlying asset. With dYdX, you can:
Leverage Up to 20x: Enhance your trading potential with leverage options tailored to your risk tolerance.
Variety of Pairs: Trade a diverse selection of cryptocurrency pairs across multiple markets.
Security at dYdX
Your security is paramount at dYdX. Our platform employs state-of-the-art security measures to protect your assets and data, ensuring peace of mind with every trade you make.
Join the dYdX Community
Join a global community of traders who are revolutionizing the way decentralized finance operates. Stay updated and connected through our social media channels and community forums.
Note: Always conduct thorough research and consider your risk tolerance before engaging in cryptocurrency transactions.
выведение из запоя врачом наркологом [url=www.vyvod-iz-zapoya-ekaterinburg25.ru]выведение из запоя врачом наркологом[/url] .
вывод из запоя цена вывод из запоя цена .
вывод из запоя дома вывод из запоя дома .
вывести из запоя цена вывести из запоя цена .
вывод из запоя в екатеринбурге [url=https://vyvod-iz-zapoya-ekaterinburg25.ru]вывод из запоя в екатеринбурге[/url] .
вывод из запоя врачом на дому вывод из запоя врачом на дому .
вывод из запоя на дому вывод из запоя на дому .
вывести из запоя цена вывести из запоя цена .
The author touched on a really important topic that needs to be talked about as often and loudly as possible https://vvunj.ilyx.ru/id-3245.html
купить аттестат в иркутске
Canl? Casino Siteleri: deneme bonusu veren casino siteleri – Canl? Casino Siteleri
нарколог на дом екатеринбург цены нарколог на дом екатеринбург цены .
Welcome to Orbiter: Your Gateway to Financial Innovation
In the ever-evolving landscape of finance, Orbiter stands out as a pioneering platform dedicated to providing cutting-edge solutions for modern investors. As we navigate the future of digital assets and decentralized finance, Orbiter remains at the forefront, committed to innovation and accessibility.
orbiter finance
Why Choose Orbiter?
Orbiter offers unique advantages that set it apart in the financial world:
Decentralized Solutions: Benefit from a trustless environment where transactions are secure and transparent.
Innovative Technologies: Leverage groundbreaking technologies, designed to maximize efficiency and utility.
Community Driven: Engage with a global community that supports and uplifts each other in the financial journey.
Key Features of Orbiter
Orbiter’s platform is rich with features tailored to both new and experienced investors.
1. Smart Investments
Utilize intelligent tools that enable you to optimize your investment strategies. Orbiter’s algorithms are crafted to pinpoint opportunities in both volatile and stable markets.
2. Secure Transactions
Enjoy peace of mind with Orbiter’s advanced security measures. Our platform ensures that each transaction is protected through top-tier encryption and blockchain technology.
3. User-Friendly Interface
Navigate with ease! Our user-friendly design ensures accessibility for everyone, from beginners to seasoned traders.
Join the Orbiter Community
By joining Orbiter, you’re becoming part of a larger movement towards decentralized and democratized finance. Share insights, learn from peers, and grow your financial acumen in the company of like-minded individuals.
Ready to explore the future of finance? Let Orbiter guide your journey towards smarter, more secure, and lucrative investments. Join us today and revolutionize how you approach financial management.
Understanding Venus Protocol: Your Gateway to DeFi
Venus Protocol has carved a niche in the fast-paced DeFi landscape by offering a one-stop solution for decentralized finance activities. Whether you’re interested in lending, borrowing, or yield farming, Venus provides secure and scalable services on the blockchain.
venus io
Why Choose Venus Protocol?
The Venus Protocol stands out because:
It operates on the Binance Smart Chain, ensuring fast and cost-effective transactions.
It offers a decentralized lending platform that allows users to earn interest by supplying assets.
The protocol enables borrowing against crypto collateral without the need for a trusted counterparty.
It supports a wide range of crypto assets, providing higher liquidity and flexibility.
Key Features of Venus Protocol
Lending and Borrowing
Venus Protocol facilitates decentralized lending and borrowing with minimal fees, supported by a robust risk management framework. Users can seamlessly supply assets to the protocol and earn interest, or borrow by simply collateralizing their holdings.
Automated Yield Farming
Maximize your returns with Venus Protocol’s yield farming opportunities. By leveraging your assets, you can participate in governance and earn rewards in the form of XVS, Venus Protocol’s native token.
Multi-Asset Support
The platform supports numerous cryptocurrencies, enabling diverse investment strategies and providing a convenient way to gain returns on multiple asset classes.
Getting Started with Venus Protocol
Start your DeFi journey with Venus Protocol by following these steps:
Create a Wallet: Use a compatible wallet like Metamask or Trust Wallet to interface with Venus.
Fund Your Wallet: Transfer crypto assets to your wallet to engage with the Venus Protocol.
Connect and Start Earning: Connect your wallet to the Venus platform and start supplying or borrowing assets.
Venus Protocol is your trusted partner in the decentralized financial ecosystem. With its advanced features and strong community support, it simplifies DeFi for everyone from beginners to seasoned users. Embrace the future of finance with confidence and start exploring the possibilities at .
Getting Started with Quickswap
Quickswap is revolutionizing the way we trade cryptocurrencies by offering a decentralized platform for seamless crypto trading. As a user-friendly decentralized exchange (DEX), Quickswap allows users to swap tokens effortlessly without the need for intermediaries. Here’s a detailed guide to getting started with Quickswap.
quickswap v2
What is Quickswap?
Quickswap is a layer-2 decentralized exchange built on the Polygon network, which is known for its high-speed and low-cost transactions. This platform provides an efficient and secure way to trade a wide range of cryptocurrencies without enduring hefty fees typical of Ethereum-based DEXes.
Why Use Quickswap?
Low Fees: Thanks to the Polygon network, trading on Quickswap is significantly cheaper than on Ethereum-based platforms.
High Speed: Experience fast transaction speeds that enhance user experience and trading efficiency.
User-Friendly Interface: Quickswap’s interface is designed to be intuitive, even for beginners, making it easy to trade cryptocurrencies.
How to Use Quickswap
Set Up a Crypto Wallet: You’ll need a compatible wallet like MetaMask or Trust Wallet. Ensure it’s connected to the Polygon network.
Fund Your Wallet: Purchase or transfer tokens into your wallet for trading.
Visit Quickswap Platform: Navigate to the Quickswap website and connect your wallet. This step is essential to access all features of the platform.
Start Trading: Select the tokens you want to swap. With its simple interface, you can execute trades in just a few clicks.
Tips for Effective Trading on Quickswap
To make the most out of your trading experience on Quickswap, consider these tips:
Keep an eye on the market trends and choose the right time for your trades.
Understand the token pairs and their liquidity status to avoid high slippage.
Regularly update your wallet and security settings to protect your assets.
Conclusion
Quickswap offers a robust platform for trading a wide range of cryptocurrencies efficiently. By leveraging the benefits of the Polygon network, it minimizes delays and costs associated with traditional crypto trading. Whether you’re a beginner or a seasoned trader, Quickswap empowers you to navigate the DeFi space with ease and confidence.
sweet bonanza giris: sweet bonanza – sweet bonanza oyna
Tennis betting https://yourmoneyblog.site best odds, predictions and analytics. Explore detailed match reviews, statistics and strategies to make successful bets. Use our tips and win!
guvenilir slot siteleri slot oyunlar? slot oyunlar? puf noktalar?
Credit Union Mobile Home Loans https://blogcredit.tech are the perfect solution for buying or refinancing a mobile home. Affordable rates, easy application, and reliable support every step of the way. Take the first step toward your home with us!