官术网_书友最值得收藏!

VueJS devtools

Being able to accurately debug our application is an important part of our development workflow. In the previous chapter, we installed the VueJS devtools, and we'll be looking at using it in more detail within this section. Let's make a playground project:

# New project
vue init webpack-simple vue-devtools

# Change directory
cd vue-devtools

# Install dependencies
npm install

# Run application
npm run dev

We can then open up our developer console and navigate to the Vue tab. When we select App from within the components list, we can see the data object(s) and other information for this component. By default, we have the msg variable that we're then binding to within our template, and we can see this within our developer tools:

Inspecting a Vue instance

This goes both ways though - we could access the objects inside of this Vue instance with $vm0.$data, scoping this to msg. To view this within the console, selecting <Root> then <App> will display the msg0;within the console. We can change this value and as Vue is watching the value, it will automatically change on screen:

Editing Vue instance data from the console

Notice how our message has changed to "Hello Vue Devtools!"; if we had multiple Vue instances, there would be other prefixed versions of Vue with $vm1, $vm2, and so on. Later in the book when we come to using Vuex, we'll be using this often. Next, let's take a look at how we can integrate TypeScript into our Vue projects. This is useful for those with an Angular background or anyone that's looking to take advantage of static typing.

主站蜘蛛池模板: 弥勒县| 平乐县| 祁阳县| 巴林右旗| 邯郸市| 师宗县| 泰安市| 丁青县| 垣曲县| 云浮市| 乌兰察布市| 赫章县| 勃利县| 鹤庆县| 新宾| 枞阳县| 万源市| 云龙县| 泾阳县| 西青区| 胶州市| 清涧县| 于田县| 田阳县| 开远市| 库尔勒市| 新巴尔虎左旗| 龙门县| 湾仔区| 酉阳| 定安县| 西充县| 蓝山县| 福建省| 汽车| 宁河县| 广东省| 巴林左旗| 德令哈市| 靖西县| 铁力市|