vue-router实现增删改查grud操作
代码语言:html
所属分类:布局界面
代码描述:vue-router实现增删改查grud操作
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/bootstrap.3.3.4.css"> <style> .logo { width: 50px; float: left; margin-right: 15px; } .form-group { max-width: 500px; } .actions { padding: 10px 0; } .glyphicon-euro { font-size: 12px; } </style> </head> <body> <div class="container"> <header class="page-header"> <div class="branding"> <h1>Vue.js CRUD application</h1> </div> </header> <main id="app"> <router-view></router-view> </main> </div> <template id="product-list"> <div class="actions"> <a class="btn btn-default" v-link="{path: '/add-product'}"> <span class="glyphicon glyphicon-plus"></span> Add product </a> </div> <div class="filters row"> <div class="form-group col-sm-3"> <label for="search-element">Product name</label> <input v-model="searchKey" class="form-control" id="search-element" requred /> </div> </div> <table class="table"> <thead> <tr> <th>Name</th> <th>Description</th> <th>Price</th> <th class="col-sm-2">Actions</th> </tr> </thead> <tbody> <tr v-for="product in products | filterBy searchKey in 'name'"> <td> <a v-link="{name: 'product', params: {product_id: product.id}}">{{ product.name }}</a> </td> <td>{{ product.description }}</td> <td> {{ product.price }} <span class="glyphicon glyphicon-euro" aria-hidden="true"></span> </td> <td> <a class="btn btn-warning btn-xs" v-link="{name: 'product-edit', params: {product_id: product.id}}">Edit</a> <a class="btn btn-danger btn-xs" v-link="{name: 'product-delete', params: {product_id: product.id}}">Delete</a> </td> </tr> </tbody> </table> </template> <template id="add-product"> <h2>Add new product</h2> <form v-on:submit="createProduct"> <div class="form-group"> <label for="add-name">Name</label> <input class="form-control" id="add-name" v-model="product.name" required /> </div> <div class="form-group"> <label for="add-description">Description</label> <textarea class="form-control" id="add-description" rows="10" v-model="product.description"></textarea> </div> <div class="form-group"> <label for="add-price">Price, <span class="glyphicon glyphicon-euro"></span></label> <input type="number" class="form-control" id="add-price" v-model="product.price" /> </div> <button type="submit" class="btn btn-primary">Create</button> <a v-link="'/'" class="btn btn-default">Cancel</a> </form> </template> <template id="product"> <h2>{{ product.name }}</h2> <b>Description: </b> <div> {{ product.description }} </div> <b>Price:</b> <div> {{ product.price }}<span class="glyphicon glyphicon-euro"></span> </div> <br /> <span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span> <a v-link="'/'">Backt to product list</a> </template> <template id="product-edit"> <h2>Edit product</h2> <form v-on:submit="updateProduct"> <div class="form-group"> <label for="edit-name">Name</label> <input class="form-control" id="edit-name" v-model="product.name" required /> </div> <div class="form-group"> <label for="edit-description">Description</label> .........完整代码请登录后点击上方下载按钮下载查看
网友评论0