表題についてです。
ボタンを押すとアラートが出るようにしたいのですがうまくいきません。
ご教授をよろしくお願いいたします。
html
1<!DOCTYPE html 2> 3<html xmlns:th="http://www.thymeleaf.org" 4 xmlns:layout="http://www.iltraq.net.nz/thymeleaf/layout" 5 layout:decorate="~{layouts/layout}" 6 lang="ja"> 7 8<head> 9 <meta charset="utf-8"> 10 <title>test</title> 11 <link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap/dist/css/bootstrap.min.css" /> 12 <link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.css" /> 13</head> 14 15<body> 16 17 <!-- メッセージエリア --> 18 <form id="form" th:action="@{/test}"> 19 <div class="py-2"> 20 <section id="information"> 21 <div class="container-fluid"> 22 <div class="row"> 23 24 <!--ボタン--> 25 <div class="col-md-12 py-5"> 26 <div class="row no-gutters"> 27 <div class="col-sm-6 col-md-6 col-lg-6 col-xl-3"> 28 <button type="button" class="btn btn-info custom-btn" @click='syukin()'>出勤</button> 29 </div> 30 <div class="col-sm-6 col-md-6 col-lg-6 col-xl-3"> 31 <button type="button" class="btn btn-danger custom-btn" @click='taikin()'>退勤</button> 32 </div> 33 <div class="col-sm-6 col-md-6 col-lg-6 col-xl-3"> 34 <button type="button" class="btn btn-success custom-btn" @click='kyukei()'>休憩</button> 35 </div> 36 </div> 37 </div> 38 </div> 39 </div> 40 </section> 41 </div> 42 </form> 43 <script src="https://polyfill.io/v3/polyfill.min.js?features=es2015%2CMutationObserver" crossorigin="anonymous"></script> 44<!-- <script src="https://code.jquery.com/jquery-3.4.1.slim.js" integrity="sha256-BTlTdQO9/fascB1drekrDVkaKd9PkwBymMlHOiG+qLI=" crossorigin="anonymous"></script> --> 45 <script src="https://unpkg.com/vue@latest/dist/vue.min.js"></script> 46 <script src="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.js"></script> 47 <script src="sample.js"></script> 48</body> 49 50</html>
javaScript
1//フォーム 2var form = new Vue({ 3 //紐づくセレクター 4 el : '#form', 5 6 //メソッド 7 method : { 8 //出勤 9 syukin : function(){ 10 alert("出勤しました。"); 11 }, 12 //退勤 13 taikin : function(){ 14 alert("退勤しました。"); 15 }, 16 //休憩 17 kyukei : function(){ 18 alert("休憩情報を登録しました。"); 19 } 20 } 21}); 22
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/07 02:14