GithubHelp home page GithubHelp logo

yahiousun / react-weixin-title Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 7.31 MB

Provides a declarative way to specify document.title in a single-page app.

Home Page: https://yahiousun.github.io/react-weixin-title/

License: MIT License

JavaScript 86.34% HTML 4.00% CSS 9.66%

react-weixin-title's Introduction

React Weixin Title

Provides a declarative way to specify document.title in a single-page app.
This component can be used on weixin for iOS as well.

Installation

npm install --save react-weixin-title

Example

Assuming you use something like react-router:

import React from 'react';
import { render } from 'react-dom';
import { Router, Route, IndexRoute, hashHistory } from 'react-router';
import { ChangeWeixinTitle } from 'react-weixin-title';

import App from './containers/App';
import Home from './routes/Home';
import GettingStarted from './routes/GettingStarted';

import './styles/styles.scss';

const title = 'React Weixin Title'; //your title here
const src = '/favicon.ico'; //a valid url, i.e. '/favicon.ico'

render((
  <Router history={hashHistory}>
    <Route path="/" component={App}>
      <IndexRoute component={Home} onEnter={() => new ChangeWeixinTitle(title, src)} />
      <Route path="getting-started" component={GettingStarted} />
    </Route>
  </Router>
), document.getElementById('app'));

Or use WeixinTitle component

import React from 'react';
import { WeixinTitle } from 'react-weixin-title';

const title = 'your title here'; //your title here
const src = '/favicon.ico'; //a valid url, i.e. favicon.ico

class Demo extends React.Component {
  render() {
    return (
      <WeixinTitle title={title} src={src}>
        //your code here
      </WeixinTitle>
    )
  }
}

Live Demo

react-weixin-title

References

微信前端开发有哪些坑或者黑魔法?

License

Copyright © 2016 yahiousun. This source code is licensed under the MIT license found in the LICENSE file.

react-weixin-title's People

Contributors

yahiousun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.