File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Demo
2
+
3
+ ``` elixir
4
+ Mix .install ([
5
+ {:phoenix_playground , " ~> 0.1.0" }
6
+ ])
7
+ ```
8
+
9
+ ## Section
10
+
11
+ ``` elixir
12
+ defmodule DemoLive do
13
+ use Phoenix .LiveView
14
+
15
+ def mount (_params , _session , socket) do
16
+ {:ok , assign (socket, count: 0 )}
17
+ end
18
+
19
+ def render (assigns) do
20
+ ~H"""
21
+ <span ><%= @count % > </span >
22
+ <button phx-click =" inc" >+</button >
23
+ <button phx-click =" dec" >-</button >
24
+
25
+ <style type =" text/css" >
26
+ body { padding : 1em ; }
27
+ span { font-family : monospace ; }
28
+ </style >
29
+ """
30
+ end
31
+
32
+ def handle_event (" inc" , _params , socket) do
33
+ {:noreply , assign (socket, count: socket.assigns.count + 1 )}
34
+ end
35
+
36
+ def handle_event (" dec" , _params , socket) do
37
+ {:noreply , assign (socket, count: socket.assigns.count - 1 )}
38
+ end
39
+ end
40
+
41
+ PhoenixPlayground .start (live: DemoLive )
42
+ ```
You can’t perform that action at this time.
0 commit comments