ã¢ããã³ã並æ¨ç²¾å¯å®ç³æ ªå¼ä¼ç¤¾ã¯Blu-Rayãã£ã¹ã¯10åæã®ãã¼ã¿ã®ä¿ç®¡ãå¯è½ã«ãããç´å¾ç´5.5cmã®è¶ é«ç´åº¦ã®ãã¤ã¤ã¢ã³ãã¦ã§ãã®éç£ã«æåããã¨çºè¡¨ãã¾ããã
â§ã硬度10ããã¤ã¤ã¢ã³ããã¯ã¼ï¼ï¼ãã³èãã³ï¼ããããªãã§ããã大容éè¨é²ãå¯è½ã¨ãããã¨ã§ããããã£ã±ããé«ããã§ããï¼ã§æ¬å½ã«ãå¤æ®µãé«ããã§æã...
TypeScriptã®ã¯ã©ã¹ãåä»ãªä»¶
Javaè³ã§èãã¦ãã¨ãã¡ãã£ã¨TypeScriptã®ã¯ã©ã¹ã«éåæãè¦ããã®ã§ããã
⧠ä¸è¨ãµã¤ãæ§ã«ããã¾ãã¨ãã©ãããã«ãã»ã«åã«é£ãããããã§ãã
ã¨ã¯è¨ããä»åã¯æéããªãã£ãã®ã§ã妥åãã¾ããã¾ãã
Vue.jsã®ã©ã¤ããµã¤ã¯ã«ã¨Vue Routerã«ããSPAï¼Single Page Applicationï¼ã®é¢ä¿ã®ç¢ºèª
ãSPAï¼Single Page Applicationï¼ãã«ã¤ãã¦ã¯ããã©ã¦ã¶ã®ãªãã¼ããã¿ã³ãæ»ããã¿ã³ãæ¼ä¸ãããªãéãããã¼ã¸ã®æ å ±ãåæåããããã¨ã¯ãªããããã§ãã¨ã
⧠ä¸è¨ãµã¤ãæ§ãã¾ã¨ãã¦ãã ãã£ã¦ã¾ãã
ãã¨ã¯ãã»ãã·ã§ã³ãåããããªããã§ãæåããããããªããããã§ãããä»åã¯ãVue.jsã®Vue Routerã§ç»é¢é·ç§»ããéã«ã
- Vue.jsã®ã©ã¤ããµã¤ã¯ã«ã®ã¡ã½ãããå¼ã°ããã¿ã¤ãã³ã°
- å¥ã¯ã©ã¹ã®å¤ã¯ä¿æããã¦ãã®ã
- Watchã«æå®ããã¡ã½ãããå¼ã°ããã¿ã¤ãã³ã°
ã¨ããå±æçãªé¨åã®ç¢ºèªã®ããã諸ã ã®èæ ®ã¯å²æãããã¾ãã
Vue.jsã§ããã©ã¦ã¶ã®æ»ããã¿ã³ãªã©ã®å¶å¾¡ã«ã¤ãã¦ã¯ã
⧠ä¸è¨ãµã¤ãæ§ãåèã«ãªãããã§ãããé²ããã¿ã³ã¨ã®åºå¥ãå¤æããè¡ããªãã¨ããã課é¡ã¨ãã£ãã¨ããã§ããããã
Vue.jsã§ããã©ã¦ã¶ã®ãªãã¼ããã¿ã³ãªã©ã®å¶å¾¡ã«ã¤ãã¦ã¯ã
⧠window.onbeforeunloadã¡ã½ããã§æ¤ç¥ããæ¹æ³ãããããã§ãã
Vue.jsã®ã©ã¤ããµã¤ã¯ã«ãªããã«ã¤ãã¦ã¯ãæåå³åã«ãªãæ縮ã§ãã
⧠ä¸è¨è¨äºã§å°ã触ãã¦ã¾ãã
ã§ããã©ã¦ã¶ã®ãªãã¼ããã¿ã³ãæ»ããã¿ã³ãªã©æ¼ä¸ããªãåæï¼ã»ãã·ã§ã³ãã¯ããã¼ãªã©ãèããªãï¼ã¨ããå ´åãä»åãåãã£ããã¨ã¨ãã¾ãã¦ã
- Vue.jsã®ã©ã¤ããµã¤ã¯ã«ã®ã¡ã½ãããå¼ã°ããã¿ã¤ãã³ã°
âã³ã³ãã¼ãã³ãã®ãã¼ã¸ã«é·ç§»ããã度ã«å¼ã°ããã - å¥ã¯ã©ã¹ã®å¤ã¯ä¿æããã¦ãã®ã
âæ示çã«åæåããªãéãä¿æããç¶ããã - Watchã«æå®ããã¡ã½ãããå¼ã°ããã¿ã¤ãã³ã°
âWatchãã¦ãå¤ãè¨å®ãããæãç»é¢çµç±ããããªãã¦ãå¤ãè¨å®ããéã«å¼ã°ããã
ã¨ããæãã«ãªãã¾ãã
åä»ãªã®ã¯ãWatchã«æå®ããã¡ã½ããã§ç£è¦ãã¦ãå¤ã«ã¤ãã¦ã¯ãå¤ãè¨å®ããã度ã«å¼ã°ããã¨ãããã¨ã§ããããã
å®éã«ã³ã¼ãã§ç¢ºèªãã¦ã¿ã¾ããã
⧠ãªãã¸ã§ã¯ãã®ããããã£ã®å¤ã空ãã©ããã®ãã§ãã¯ã¯ãä¸è¨ãµã¤ãæ§ãåèã«ããã¦ããã ãã¾ããã
Vue.jsã®ããã¸ã§ã¯ãã¨ãã¦ã¯ã
⧠ä¸è¨ã®æã®ãã®ã«è¿½å ãã¦ããæãã§ãã
ã¤ã³ã¹ãã¼ã«ããã¦ãnpmã®ã¢ã¸ã¥ã¼ã«ã¯ä»¥ä¸ã®ãããªæãã
{ "name": "my-project-vue", "version": "0.1.0", "private": true, "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint" }, "dependencies": { "vue": "^2.6.14", "vue-class-component": "^7.2.3", "vue-property-decorator": "^9.1.2", "vue-router": "^3.5.1" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/parser": "^5.4.0", "@vue/cli-plugin-eslint": "~5.0.0", "@vue/cli-plugin-router": "~5.0.0", "@vue/cli-plugin-typescript": "~5.0.0", "@vue/cli-service": "~5.0.0", "@vue/eslint-config-typescript": "^9.1.0", "axios": "^0.26.1", "element-ui": "^2.15.8", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-vue": "^8.0.3", "prettier": "^2.4.1", "sass": "^1.32.7", "sass-loader": "^12.0.0", "typescript": "~4.5.5", "vue-template-compiler": "^2.6.14" } }
ã§ãä»å追å ãã¦ããã¡ã¤ã«ã¯ã
⧠é¸æããã¦ãã¨ãããæ°ãã追å ãããã®ã«ãªãã¾ãã
â C:\Users\Toshinobu\Desktop\soft_work\vue_work\vue-router-work\my-project-vue\src\modules\user\user.model.ts
interface UserModelType { id: string; lastName: string; firstName: string; age: string; birthday: any; } class UserModel implements UserModelType { id = ""; lastName = ""; firstName = ""; age = ""; birthday = ""; constructor(init?: Partial<UserModel>) { Object.assign(this, init); } } export default new UserModel();
â C:\Users\Toshinobu\Desktop\soft_work\vue_work\vue-router-work\my-project-vue\src\service\user\userServiceImpl.ts
class UserServiceImpl { public setUserModel(UserModel: any, formDataModel: any) { Object.assign(UserModel, { id: formDataModel.id, lastName: formDataModel.lastName, firstName: formDataModel.firstName, age: formDataModel.age, birthday: formDataModel.birthday, }); } public clearUserModel(UserModel: any) { Object.assign(UserModel, { id: "", lastName: "", firstName: "", age: "", birthday: "", }); } } export default new UserServiceImpl();
â C:\Users\Toshinobu\Desktop\soft_work\vue_work\vue-router-work\my-project-vue\src\views\user\list.vue
<template> <div> <el-table :data="userList" stripe style="width: 100%"> <el-table-column prop="id" label="ID" width="180"> </el-table-column> <el-table-column prop="lastName" label="æ°" width="180"> </el-table-column> <el-table-column prop="firstName" label="å"> </el-table-column> <el-table-column prop="age" label="å¹´é½¢"> </el-table-column> <el-table-column prop="birthday" label="çå¹´ææ¥"> </el-table-column> <el-table-column> <template slot-scope="scope"> <el-button size="mini" @click="handleEdit(scope.$index, scope.row)" >Edit</el-button > <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)" >Delete</el-button > </template> </el-table-column> </el-table> </div> </template> <script lang="ts"> /* eslint-disable no-console */ import { Component, Vue, Watch } from "vue-property-decorator"; import UserModel from "@/modules/user/user.model"; import UserServiceImpl from "@/service/user/userServiceImpl"; @Component export default class UserList extends Vue { private userList = [ { id: 1, lastName: "é´æ¨", firstName: "ä¸é", age: "38", birthday: "1983-07-20 15:00:00", }, { id: 2, lastName: "ä½è¤", firstName: "äºé", age: "39", birthday: "1982-07-20 15:00:00", }, { id: 3, lastName: "é«æ©", firstName: "ä¸é", age: "40", birthday: "1981-07-20 15:00:00", }, ]; created() { console.log("â list"); } private handleEdit(index: number, row: any) { console.log(row); if (row.id) { UserServiceImpl.setUserModel(UserModel, row); this.$router.push({ name: "/user/edit", params: { id: String(row.id) } }); } } private handleDelete(index: number, row: any) { console.log(row); } } </script>
â C:\Users\Toshinobu\Desktop\soft_work\vue_work\vue-router-work\my-project-vue\src\views\user\edit\index.vue
<template> <div class="app-container"> <el-form :model="formDataModel" ref="formDataModel"> <el-form-item label="æ°"> <el-input v-model="formDataModel.lastName"></el-input> </el-form-item> <el-form-item label="å"> <el-input v-model="formDataModel.firstName"></el-input> </el-form-item> <el-form-item label="å¹´é½¢"> <el-input v-model="formDataModel.age"></el-input> </el-form-item> <div id="datetime"> <div class="block"> <el-date-picker v-model="formDataModel.birthday" type="datetime" placeholder="æ¥ä»ã®é¸æ" > </el-date-picker> </div> </div> <el-form-item size="large"> <el-button type="primary" @click="goConfirm">確èª</el-button> <el-button @click="goBackList">æ»ã</el-button> </el-form-item> </el-form> </div> </template> <script lang="ts"> /* eslint-disable */ /* eslint-disable no-console */ import { Component, Vue, Watch } from "vue-property-decorator"; import UserModel from "@/modules/user/user.model"; import UserServiceImpl from '@/service/user/userServiceImpl'; @Component export default class UserFormEdit extends Vue { private formDataModel: any = {}; // ã©ã¤ããµã¤ã¯ã«ã®ã¡ã½ãã created() { console.log("â created()") if (this.$route.params.id) { let id :any = this.$route.params.id; console.log("â this.$route.params.id"); console.log(id); //this.$router.push } console.log("â UserModel") console.dir(UserModel) // 確èªç»é¢ããVue Routerçµç±ã§æ»ã£ã¦ããå ´å if (!this.isEmpty(UserModel)) { console.log("â åè¨å®"); this.formDataModel = Object.assign({}, this.formDataModel, { id: UserModel.id, lastName: UserModel.lastName, firstName: UserModel.firstName, age: UserModel.age, birthday: UserModel.birthday }); } console.dir(this.formDataModel); } // 確èªç»é¢ã«é·ç§» private goConfirm() { console.log("â goConfirm()"); this.formDataModel; console.dir(this.formDataModel); UserServiceImpl.setUserModel(UserModel, this.formDataModel); this.$router.push({ name: "/user/confirm", params: { formDataModel: this.formDataModel } }); } // ä¸è¦§ç»é¢ã«é·ç§» private goBackList() { // ã¦ã¼ã¶ã¼æ å ±åæå if(!this.isEmpty(UserModel)) { UserServiceImpl.clearUserModel(UserModel); } this.$router.go(-1); } /** * Objectã®åããããã£ã®å¤ããã¹ã¦ç©ºãç¢ºèª * @param model ããããã£ã®å¤ããã¹ã¦ç©ºã調ã¹ãããªãã¸ã§ã¯ã * @returns true: ããããã£ã®å¤ããã¹ã¦ç©ºãfalse:å¤ã空ã§ãªãããããã£ã®å¤ãåå¨ãã */ private isEmpty(model: any) { const isNullUndefEmptyStr = Object.values(model).every(value => { // check for multiple conditions if (value === null || value === undefined || value === '') { return true; } return false; }); return isNullUndefEmptyStr; } @Watch("formDataModel.lastName") private watchLastName() { console.log("â @Watch formDataModel.lastName") console.dir(this.formDataModel.lastName) } @Watch("formDataModel.firstName") private watchFirstName() { console.log("â @Watch formDataModel.firstName") console.dir(this.formDataModel.firstName) } @Watch("formDataModel.age") private watchFirstAge() { console.log("â @Watch formDataModel.age") console.dir(this.formDataModel.age) } @Watch("formDataModel.birthday") private watchFirstBirthday() { console.log("â @Watch formDataModel.birthday") console.dir(this.formDataModel.birthday) } } </script> <style lang="scss" scoped> .app-container { max-width: 640px; margin: auto; } </style>
â C:\Users\Toshinobu\Desktop\soft_work\vue_work\vue-router-work\my-project-vue\src\views\user\confirm\index.vue
<template> <div> <el-form ref="form" :model="formDataModel" label-width="120px" size="mini"> <div>{{ formDataModel.lastName }}</div> <div>{{ formDataModel.firstName }}</div> <div>{{ formDataModel.age }}</div> <div>{{ formDataModel.birthday }}</div> <el-form-item size="large"> <el-button type="primary" @click="goSave">ç»é²</el-button> <el-button @click="goBackEdit">æ»ã</el-button> </el-form-item> </el-form> </div> </template> <script lang="ts"> /* eslint-disable */ /* eslint-disable no-console */ import { Component, Vue, Watch } from "vue-property-decorator"; import UserModel from "@/modules/user/user.model"; @Component export default class UserFormEdit extends Vue { private formDataModel: any = {}; // ã©ã¤ããµã¤ã¯ã«ã®ã¡ã½ãã created() { console.log("â created() confirm") if (this.$route.params.formDataModel) { console.dir(this.$route.params.formDataModel) this.formDataModel = this.$route.params.formDataModel; } } private goSave() { console.log("â TODO"); } private goBackEdit() { this.$router.go(-1); } } </script>
â C:\Users\Toshinobu\Desktop\soft_work\vue_work\vue-router-work\my-project-vue\src\router\index.ts
import Vue from "vue"; import VueRouter, { RouteConfig } from "vue-router"; import HomeView from "../views/HomeView.vue"; Vue.use(VueRouter); const routes: Array<RouteConfig> = [ { path: "/", name: "home", component: HomeView, }, { path: "/about", name: "about", // route level code-splitting // this generates a separate chunk (about.[hash].js) for this route // which is lazy-loaded when the route is visited. component: () => import(/* webpackChunkName: "about" */ "../views/AboutView.vue"), }, // { // path: "/test", // name: "test", // component: () => import("../views/NavigationGuard.vue"), // }, // { // path: "/testdom", // name: "testdom", // component: () => import("../views/TestDom.vue"), // }, { path: "/testui", name: "testui", component: () => import("../views/TestElementUi.vue"), }, { path: "/user/list", component: () => import("../views/user/list.vue"), }, { path: "/user/edit/:id", name: "/user/edit", component: () => import("../views/user/edit/index.vue"), //props: (route) => ({ id: Number(route.params.id) }), }, { path: "/user/confirm", name: "/user/confirm", component: () => import("../views/user/confirm/index.vue"), //props: (route) => ({ id: Number(route.params.id) }), }, ]; const router = new VueRouter({ mode: "history", base: process.env.BASE_URL, routes, }); export default router;
â C:\Users\Toshinobu\Desktop\soft_work\vue_work\vue-router-work\my-project-vue\src\main.ts
import Vue from "vue"; import App from "./App.vue"; import router from "./router"; import Element from "element-ui"; // ElementUIã§ã®è¨èªè¨å®ãdatePickerã¨ãã§é©ç¨ããã import locale from "element-ui/lib/locale/lang/ja"; import "element-ui/lib/theme-chalk/index.css"; Vue.config.productionTip = false; Vue.use(Element, { locale }); new Vue({ router, render: (h) => h(App), }).$mount("#app");
â C:\Users\Toshinobu\Desktop\soft_work\vue_work\vue-router-work\my-project-vue\src\App.vue
import UserFormEdit from './views/user/edit/index.vue'; <template> <div id="app"> <nav> <router-link to="/">Home</router-link> | <router-link to="/about">About</router-link> | <!-- <router-link to="/testdom">dom</router-link> | --> <router-link to="/testui">UI</router-link> | <router-link to="/user/list">User</router-link> </nav> <router-view /> </div> </template> <style lang="scss"> #app { font-family: Avenir, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; } nav { padding: 30px; a { font-weight: bold; color: #2c3e50; &.router-link-exact-active { color: #42b983; } } } </style>
⧠å®éã¯ãµã¼ãã¼ãµã¤ãã¨é£æºãã¦ãã¼ã¿ãåå¾ãããã¨ãä¸è¬çã¨ã¯æãã®ã§ãããä»åã¯ãé©å½ãªãã¼ã¿ãã¹ãæ¸ãã§ã
éçºç¨ãµã¼ãã¼èµ·åã§ã
VS Codeï¼Visual Studio Codeï¼ã®ã¿ã¼ããã«ã«è¡¨ç¤ºããã¦ãURLã«ãã©ã¦ã¶ã§ã¢ã¯ã»ã¹ãã¾ããããããããã¼ãã¼ã«ãã表示ãã¦ãããUserã®ãªã³ã¯ãæ¼ä¸ãã¦ãã¼ã¸é·ç§»ãããEditããã¿ã³ãæ¼ä¸ã
ããããããã¼ãã¼ã«ãã®ãConsoleãã確èªããã¨ãuser.model.tsã®ã¤ã³ã¹ã¿ã³ã¹ãçæã§ãã¦ã¾ãã
ã確èªããã¿ã³ãæ¼ä¸ã
ããããããã¼ãã¼ã«ãã®ãConsoleãã確èªããã¨ãuser.model.tsã®ã¤ã³ã¹ã¿ã³ã¹ã®å¤ãç¶æããã¦ã¾ãããæ»ãããã¿ã³ãæ¼ä¸ãã¦ã¿ã¾ãã
user.model.tsã®ã¤ã³ã¹ã¿ã³ã¹ã®å¤ãç¶æããã¦ã¾ãã
å¤ãåè¨å®ããã¨ãWatchã®ã¡ã½ãããå¼ã°ããã®ã確èªã§ãã¾ãã
ã¨ããããã§ãVue.jsã®ã©ã¤ããµã¤ã¯ã«ã®ã¡ã½ããã¯ããã¼ã¸é·ç§»ããã度ã«å¼ã°ããã¨ãããã¨ã確èªã§ãã¾ããã
ã¾ããVuexã使ããªãå ´åã§ãããã©ã¦ã¶ã®ãªãã¼ããã¿ã³ãªã©ãæ¼ä¸ããããªã©ãå¤é¨ããã®å½±é¿ããªããã°ãå¤ã¯ç¶æããç¶ããããã§ãã
å®éã¯ããªãã¼ãããã¦ã大ä¸å¤«ãªããã«å¶å¾¡ãªã©ãå¿ è¦ã¨ãããã¨ã§ãããããã
ãã¨ãæ¥ä»ã¨ãã®ãã©ã¼ããã調æ´ã«é¢ãã¦ã¯ãä»åã¯å°å ¥ãã¦ããªãã®ã§ããMoment.jsã¨ãããã®ãæåãããã§ãã
ã§ããï¼
⧠æ°è¦ããã¸ã§ã¯ãã§å°å ¥ããã®ã¯éæ¨å¥¨ã«ãªã£ã¦ããããã§ã...
ãï½ãã代æ¿ã¨ãªãã©ã¤ãã©ãªã§æ å ±ãå å®ãã¦ããã¦ããªãè¯ãã®ã§ãã...
æ¯åº¦ã¢ã¤ã¢ã¤æãå端ãªã...
ä»åã¯ãã®ã¸ãã§ã
Â