@160over90/vue-form-fetch 中文文档教程

发布于 5年前 浏览 26 项目主页 更新于 3年前

FormFetch

Features

允许您使用 HTTP 方法 GETPOST 发送或获取从任意数量的表单字段收集的数据。

如果你没有 yarn,你可以在这里下载它。

Instructions for global registration

yarn add @160over90/vue-form-fetch

包含在 main.js(应用入口点)

import FormFetch from '@160over90/vue-form-fetch';

Vue.use(FormFetch);

Instructions for editing this package

yarn install

Compiles and hot-reloads for development

yarn run serve

Attributes

方法 method 属性不包括“GET”或“POST”HTTP 方法。

行动 action 属性不包括您的 API 端点或 PHP 中间件的路径。

示例

<FormFetch
  method="POST"
  action="/submit-form.php"
>
  <template slot-scope="{ state, response }">
    <div>
      <label>
        <div>First Name</div>
        <input name="firstName">
      </label>
    </div>
    <div>
      <label>
        <div>Last Name</div>
        <input name="lastName">
      </label>
      </div>
      <button v-text="'Submit'"/>
      <p v-if="state === 'pending'>
        Submitting your request...
      </p>
      <p v-else-if="state === 'rejected'">
        Sorry, that didn't work!
      </p>
      <p v-else-if="state === 'fulfilled'">
        {{ response.ok
          ? "You're good to go!"
          : "Sorry, that didn't work!"
        }}
      </p>
  </template>
</FormFetch>

Props

init(对象,默认值:null) 允许您传递配置对象。

示例

<FormFetch
  method="POST"
  action="/submit-form.php"
  :init="{
    mode: 'cors',
    cache: 'no-cache',
  }"
>
...

请求属性请参考:https://developer.mozilla.org/en-US/docs/Web/API/Request。

License

麻省理工学院

FormFetch

Features

Allows you to use the HTTP methods GET and POST to send or get data gathered from any number of form fields.

If you do not have yarn you can download it here.

Instructions for global registration

yarn add @160over90/vue-form-fetch

Include in main.js (app entry point)

import FormFetch from '@160over90/vue-form-fetch';

Vue.use(FormFetch);

Instructions for editing this package

yarn install

Compiles and hot-reloads for development

yarn run serve

Attributes

method the method attribute excepts the "GET" or "POST" HTTP methods.

action the action attribute excepts your API endpoint or path to PHP middleware.

Example

<FormFetch
  method="POST"
  action="/submit-form.php"
>
  <template slot-scope="{ state, response }">
    <div>
      <label>
        <div>First Name</div>
        <input name="firstName">
      </label>
    </div>
    <div>
      <label>
        <div>Last Name</div>
        <input name="lastName">
      </label>
      </div>
      <button v-text="'Submit'"/>
      <p v-if="state === 'pending'>
        Submitting your request...
      </p>
      <p v-else-if="state === 'rejected'">
        Sorry, that didn't work!
      </p>
      <p v-else-if="state === 'fulfilled'">
        {{ response.ok
          ? "You're good to go!"
          : "Sorry, that didn't work!"
        }}
      </p>
  </template>
</FormFetch>

Props

init (Object, Default: null) Allows you to pass a configuration object.

Example

<FormFetch
  method="POST"
  action="/submit-form.php"
  :init="{
    mode: 'cors',
    cache: 'no-cache',
  }"
>
...

For request properties, refer to: https://developer.mozilla.org/en-US/docs/Web/API/Request.

License

MIT

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文