質問編集履歴

1

コードの追加

2018/02/26 01:14

投稿

hiropo
hiropo

スコア21

test CHANGED
File without changes
test CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  RailsにVueを導入してDBに保存した値をedit画面にて表示しようと試みています。
4
4
 
5
- この時、コントローラーでセットした @Book = Book.find(params[:id])をvue側に渡してフォームに表示させるにはどうしたらよいのでしょうか?
5
+ この時、コントローラーでセットした @ = Book.find(params[:id])をvue側に渡してフォームに表示させるにはどうしたらよいのでしょうか?
6
6
 
7
- (Bookは id とnameのみ持っているとします。)
7
+ (Bookは id とname recruiting_periodを持っているとします。)
8
8
 
9
9
  コントローラの@Bookの値をvue側に表示させる方法がわかりません。
10
10
 
@@ -16,4 +16,62 @@
16
16
 
17
17
 
18
18
 
19
+ 下記のコード内の'123'の部分をコントローラーでセットしたbook.recruiting_periodのようにして表示したいです。
20
+
21
+ return {recruiting_period: '123'}
22
+
23
+
24
+
25
+ ```
26
+
27
+ <template>
28
+
29
+ <div id="recruiting_period">
30
+
31
+ <el-date-picker v-model="recruiting_period" format="yyyy-MM-dd hh:mm" type="datetime" name="book[recruiting_period]" placeholder="日時を選択してください"></el-date-picker>
32
+
33
+ </div>
34
+
35
+
36
+
37
+
38
+
39
+ </template>
40
+
41
+
42
+
43
+ <script>
44
+
45
+ import Vue from 'vue'
46
+
47
+ import ElementUI from 'element-ui'
48
+
49
+ import locale from 'element-ui/lib/locale/lang/ja'
50
+
51
+ import 'element-ui/lib/theme-chalk/index.css'
52
+
53
+
54
+
55
+ Vue.use(ElementUI, {locale})
56
+
57
+
58
+
59
+ export default {
60
+
61
+ name: 'recruiting_period',
62
+
63
+ data () {
64
+
65
+ return {recruiting_period: '123'}
66
+
67
+ }
68
+
69
+ }
70
+
71
+
72
+
73
+ </script>
74
+
75
+ ```
76
+
19
77
  ご教授お願いします