Closed youfun closed 2 months ago
my env: Erlang/OTP 26 [erts-14.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]
Elixir 1.16.2 (compiled with Erlang/OTP 26)
{:jason, "~> 1.2"},
{:live_svelte, "~> 0.13.1"},
{:phoenix, "~> 1.7.11"},
I moved the file from the example project, and the page(live_log_list.ex and LogList.svelte)works. This means the live_svelte environment is set up correctly.
I found a way to solve this problem. I added the Json.Encoder in the schema file, and then it worked.
@derive {Jason.Encoder, only: [:id, :url, :user_id]}
schema "links" do
field :url, :string
belongs_to :user, Test.Accounts.User
timestamps(type: :utc_datetime)
end
Is that the ideal way to fix this problem?"
Good to hear you managed to solve this! This is the way to fix that issue. It's documented here: https://github.com/woutdp/live_svelte?tab=readme-ov-file#ecto
I'm not sure if it was a bug or just an unsupported feature. or mabye i use it in the wrong way
When I use the live_view, it works. The code looks like the following:
When I switch to using Svelte instead, it stops working ande the page show me error:
I add a "render(assigns)" and not change the code in" def mount " The code looks like the following:
the data i get by use ecto ,like this:
may i should use the live_json?