Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Vue component to wrap non SSR friendly components (428 bytes)

License

NotificationsYou must be signed in to change notification settings

egoist/vue-client-only

Repository files navigation

NPM versionNPM downloadsCircleCIdonate

Install

yarn add vue-client-only

This project is previously known asvue-no-ssr, switch to1.x branch for the old docs.

Usage

<template>  <divid="app">    <h1>My Website</h1>    <client-only><!-- this component will only be rendered on client-side-->      <comments />    </client-only>  </div></template><script>importClientOnlyfrom'vue-client-only'exportdefault {    components: {      ClientOnly    }  }</script>

Placeholder

Use a slot or text as placeholder until<client-only /> is mounted on client-side.

eg, show a loading indicator.

<template>  <divid="app">    <h1>My Website</h1><!-- use slot-->    <client-only>      <comments />      <comments-placeholderslot="placeholder" />    </client-only><!-- or use text-->    <client-onlyplaceholder="Loading...">      <comments />    </client-only>  </div></template><script>importClientOnlyfrom'vue-client-only'exportdefault {    components: {      ClientOnly    }  }</script>

By default the placeholder will be wrapped in adiv tag, however you can useplaceholderTag prop to customize it:

<client-only placeholder="loading" placeholder-tag="span">  <comments /></client-only>

And you get:

<spanclass="client-only-placeholder">  loading</span>

If propplaceholder is an empty string (ornull) and noplaceholderslot is found, then<client-only> will render the Vue placeholder element<!---->instead of rendering theplacholder-tag during SSR render.

Development

yarn install# Run exampleyarn example

Contributing

  1. Fork it!
  2. Create your feature branch:git checkout -b my-new-feature
  3. Commit your changes:git commit -am 'Add some feature'
  4. Push to the branch:git push origin my-new-feature
  5. Submit a pull request :D

Author

vue-client-only ©egoist, Released under theMIT License.
Authored and maintained by egoist with help from contributors (list).

egoist.moe · GitHub@egoist · Twitter@_egoistlily

About

Vue component to wrap non SSR friendly components (428 bytes)

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors8


[8]ページ先頭

©2009-2025 Movatter.jp