Skip to main content

Vue.js

I had the example from a YouTube Tutorial on Vue working, but I'm having a little trouble creating an empty project for my own development.



Part of the issue is that Vue is compiled. What you're running is minified (or not) JavaScript that includes a ton of stuff along with your app. So you can write a little, compile it, look at it in a browser (using the WAMP server) and repeat those steps to death, or you can use their system development which automatically compiles and auto-runs when it notices a source code change.

vue ui

brings up an app (at /localhost:8000) that manages this process, in theory, but I've forgotten the mechanics of it.

In the example, we had a tree:

public
`--src
     `--App.vue
     `--views
     |    `--Home.vue
     |    `--About.vue
     `--components
          `--Todos.vue
          `--TodoItem.vue
          `--AddTodo.vue
          `--layout
               `--Header.vue

Each .vue file in the tutorial had three sections:

<template>
   HTML here with {{data inserts}} and v-if, v-bind in HTML elements
</template>

<script>
   JavaScript such as an object literal export { name, props, methods }
</script>

<style scoped>
   CSS for the template HTML
   The 'scoped' attribute means it only affects the template
</style>


The .vue files in the /views dir had the same sections, but in the template, we refer to components as if they were HTML elements. So a <div> might include an <AddTodo>.

So, the command line vue tool can do many things:

vue create <app-name>  - creates a new project (this is where I went wrong, I cloned the directory)
vue add <plugin>
vue invoke <plugin>
vue serve - create a local development server
vue build - minify for release
vue ui - display the dashboard in the browser
vue config - inspect and modify the config
vue info - print debug info about the environment

Tutorial Steps

* @7:17 Use Node.js, NPM (Node Package Manager). Download Vue.js devtools for Chrome. Vue.js
* npm install -g @vue/cli
* vue --version to see it
* vue create test - Choose default babel, eslint plugins. npm run serve.
** Or use the vue ui - Click 'Create' choose the folder, give it a name. Default preset babel, eslint
** Plugins will include vue/cli, babel, eslint
** Tasks let you serve, build, lint, inspect. Click serve, then Run task.
** Click Open App
* Open the source in VS Code.
** package.json - keeps the dependencies
** public/index.html is the page served in the browser
** src/main.js is the main entry point; it creates a new Vue()
** App.vue is also an entry point. Template/Script/Style - style here can be global for the app
** If you're using a Component name in your Template, you'll likely import it in your Script section.

Comments

Popular posts from this blog

A JSON Db Product?

The last post "solved" the problem of many-to-many table joins by papering over the association table with a RESTful JSON interface. As long as we're using JSON, we might as well take advantage of multi-valued table cells. I'm naturally wondering where this leads. JSON identifiers and types and SQL identifiers and types overlap so much that their intersection is a useful subset. Camel-case fields in string, number, bool flavors. Many-to-many occurs often in the world: Students in Classes Actors in Films (musicians on recorded songs) Parts in Assemblies Customers and Products (joined by Orders) The generalized description is that a Table requires a unique identifier for each row. Tables list students, actors, films, customers, and so on.  An Association Table is has two or more foreign keys that match unique identifiers in other tables. The knowledge of how a FK maps to a specific Table is baked in--we wouldn't want a "table name" column....

JSON/MySQL Schemas

As noted previously, there is a lot of overlap between the RDBMS world and the JSON world. Identifiers JSON is defined to allow identifiers of any kind of Unicode string, encoded in UTF-8 (or UTF-16, etc.). They begin and end with double quotation marks (U+0022), so included quotation marks and '\' must be escaped as \" or \\. Control characters (ASCII 0-x1F) must be escaped as well. In practice, JSON identifiers conform to ECMAScript standards . There are some 68  reserved keywords (function, import, for, if, else, and so on) that should not be used as identifiers. Unexpected reserved words include abstract, await, debugger, delete, finally, instanceof, super, synchronized, transient, volatile, and yield. The spec makes a distinction between identifiers and IdentifierNames (specifically, array keys), but why risk it? ECMAScript allows '$' and '_' anywhere in an identifier. Length or camelCasing are not part of the spec. As for length, there seems t...