Users

Reqres user API を利用したアプリケーションのサンプル。

項目

Route

# id email first_name last_name avatar
-- 1 -- 1george.bluth@reqres.inGeorgeBluthCard image cap
-- 2 -- 2janet.weaver@reqres.inJanetWeaverCard image cap
-- 3 -- 3emma.wong@reqres.inEmmaWongCard image cap
-- 4 -- 4eve.holt@reqres.inEveHoltCard image cap
-- 5 -- 5charles.morris@reqres.inCharlesMorrisCard image cap
-- 6 -- 6tracey.ramos@reqres.inTraceyRamosCard image cap
vue
<template>
  <b-table striped>
    <thead>
      <tr>
        <th scope="col">
          #
        </th>
        <th scope="col">
          id
        </th>
        <th scope="col">
          email
        </th>
        <th scope="col">
          first_name
        </th>
        <th scope="col">
          last_name
        </th>
        <th scope="col">
          avatar
        </th>
      </tr>
    </thead>
    <tbody>
      <c-list-item
        v-slot="{ item }"
        tag="tr"
        state-src="reqres://users"
        state-path="data"
      >
        <th scope="row">
          <c-link
            state-src="query://uid"
            :state-to="item.id"
          >
            -- {{ item.id }} --
          </c-link>
        </th>
        <td>{{ item.id }}</td>
        <td>{{ item.email }}</td>
        <td>{{ item.first_name }}</td>
        <td>{{ item.last_name }}</td>
        <td>
          <b-img
            :src="item.avatar"
            alt="Card image cap"
          />
        </td>
      </c-list-item>
    </tbody>
  </b-table>
</template>

<script setup>

</script> 
vue
<template>
  <c-data
    v-slot="uid"
    state-src="query://uid"
  >
    <c-data
      v-if="uid.data"
      v-slot="{ data }"
      :state-src="`reqres://users/${uid.data}`"
      state-path="data"
    >
      <Row margin="b-3">
        <BColFormLabel
          for="staticEmail"
          class="col-sm-2"
        >
          Email
        </BColFormLabel>
        <Col col="sm-10">
          <BFormInput
            id="staticEmail"
            type="text"
            readonly="plaintext"
            :value="`${data.email}`"
          />
        </Col>
      </Row>
      <Row margin="b-3">
        <BColFormLabel
          for="inputPassword"
          class="col-sm-2"
        >
          first_name
        </BColFormLabel>
        <Col col="sm-10">
          <BFormInput
            id="inputPassword"
            type="text"
            :value="data.first_name"
          />
        </Col>
      </Row>
    </c-data>
  </c-data>
</template>

<script setup>
</script> 

State

# id email first_name last_name avatar
-- 1 -- 1george.bluth@reqres.inGeorgeBluthCard image cap
-- 2 -- 2janet.weaver@reqres.inJanetWeaverCard image cap
-- 3 -- 3emma.wong@reqres.inEmmaWongCard image cap
-- 4 -- 4eve.holt@reqres.inEveHoltCard image cap
-- 5 -- 5charles.morris@reqres.inCharlesMorrisCard image cap
-- 6 -- 6tracey.ramos@reqres.inTraceyRamosCard image cap
vue
<template>
  <b-table striped>
    <thead>
      <tr>
        <th scope="col">
          #
        </th>
        <th scope="col">
          id
        </th>
        <th scope="col">
          email
        </th>
        <th scope="col">
          first_name
        </th>
        <th scope="col">
          last_name
        </th>
        <th scope="col">
          avatar
        </th>
      </tr>
    </thead>
    <tbody>
      <c-list-item
        v-slot="{ item }"
        tag="tr"
        state-src="reqres://users"
        state-path="data"
      >
        <th scope="row">
          <c-link
            state-src="state://selected-user"
            :state-to="item.id"
          >
            -- {{ item.id }} --
          </c-link>
        </th>
        <td>{{ item.id }}</td>
        <td>{{ item.email }}</td>
        <td>{{ item.first_name }}</td>
        <td>{{ item.last_name }}</td>
        <td>
          <b-img
            :src="item.avatar"
            alt="Card image cap"
          />
        </td>
      </c-list-item>
    </tbody>
  </b-table>
</template>

<script setup>

</script> 
vue
<template>
  <c-data
    v-slot="uid"
    state-src="state://selected-user"
  >
    <c-data
      v-if="uid.data"
      v-slot="{ data }"
      :state-src="`reqres://users/${uid.data}`"
      state-path="data"
    >
      <Row margin="b-3">
        <BColFormLabel
          for="staticEmail"
          class="col-sm-2"
        >
          Email
        </BColFormLabel>
        <Col col="sm-10">
          <BFormInput
            id="staticEmail"
            type="text"
            readonly="plaintext"
            :value="`${data.email}`"
          />
        </Col>
      </Row>
      <Row margin="b-3">
        <BColFormLabel
          for="inputPassword"
          class="col-sm-2"
        >
          first_name
        </BColFormLabel>
        <Col col="sm-10">
          <BFormInput
            id="inputPassword"
            type="text"
            :value="data.first_name"
          />
        </Col>
      </Row>
    </c-data>
  </c-data>
</template>