|
- Using Vue with TypeScript
Projects scaffolded via create-vue include pre-configured tsconfig json The base config is abstracted in the @vue tsconfig package Inside the project, we use Project References to ensure correct types for code running in different environments (e g app code and test code should have different global variables)
- KeepAlive - Vue. js
Include Exclude By default, <KeepAlive> will cache any component instance inside We can customize this behavior via the include and exclude props Both props can be a comma-delimited string, a RegExp, or an array containing either types:
- Vue and Web Components
SFC as Custom Element defineCustomElement also works with Vue Single-File Components (SFCs) However, with the default tooling setup, the <style> inside the SFCs will still be extracted and merged into a single CSS file during production build When using an SFC as a custom element, it is often desirable to inject the <style> tags into the custom element's shadow root instead
- Routes Matching Syntax - Vue Router
Custom regex in params When defining a param like :userId, we internally use the following regex ([^ ]+) (at least one character that isn't a slash ) to extract params from URLs This works well unless you need to differentiate two routes based on the param content Imagine two routes :orderId and :productName, both would match the exact same URLs, so we need a way to differentiate them
- HTML and Static Assets - Vue CLI
Result filenames include content hashes so you don’t need to worry about browsers caching their old versions The public directory is provided as an escape hatch, and when you reference it via absolute path, you need to take into account where your app will be deployed
- Single-File Components - Vue. js
<style> tags inside SFCs are typically injected as native <style> tags during development to support hot updates For production they can be extracted and merged into a single CSS file You can play with SFCs and explore how they are compiled in the Vue SFC Playground In actual projects, we typically integrate the SFC compiler with a build tool such as Vite or Vue CLI (which is based on
- Using Axios to Consume APIs — Vue. js
See the Pen Third Step Axios and Vue by Vue on CodePen Dealing with Errors There are times when we might not get the data we need from the API There are several reasons that our axios call might fail, including but not limited to:
- Ways of Using Vue
Ways of Using Vue We believe there is no "one size fits all" story for the web This is why Vue is designed to be flexible and incrementally adoptable
|
|
|