小编Kei*_*ker的帖子

如果我想在 React 中使用像 AOS 这样的 javascript 库,如何?

我想在我的 React 应用程序中使用 JavaScript 库 AOS ( https://michalsnik.github.io/aos/ )。如何将它包含在我的 App.js 文件中?

import React from 'react';
import logo from './logo.svg';
import './App.css';
import 'aos';

function App() {

  AOS.init();

  return (
    <div className="App">
      <header className="App-header">
        <img data-aos={"fade-left"} src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;

Run Code Online (Sandbox Code Playgroud)

AOS需要初始化,所以我觉得我需要做一些我在上面代码中所做的事情,但它抛出了一个错误:

无法编译 ./src/App.js Line 8:3: 'AOS' is not defined no-undef

我将如何在反应中实现这一点?

javascript shared-libraries npm reactjs

8
推荐指数
3
解决办法
1万
查看次数

在图形应用程序中,为什么着色器在运行时加载到应用程序中?

用 GLSL 等编写的着色器通常在运行时加载到图形应用程序中。我想知道为什么不直接使用着色器编译应用程序,这样以后就不必加载它们了。像这样:

#define glsl(version, glsl) "#version " #version "\n" #glsl

namespace glsl { namespace vs {
//VERTEX SHADERS
//=========================
// simple VS
//=========================
constexpr GLchar * const simple = glsl(450 core, 
    layout(location = 0) in vec3 position;

    void main() {
        gl_Position = vec4(position, 1.0f);
    }
    );

} namespace fs {
//FRAGMENT SHADERS
//=========================
// simple FS
//=========================
constexpr GLchar * const simple = glsl(450 core,
    out vec4 color;

    void main() {
        color = vec4(1.0f, 0.0f, 0.0f, 1.0f);
    }       
    ); …
Run Code Online (Sandbox Code Playgroud)

c++ opengl performance shader glsl

7
推荐指数
1
解决办法
1761
查看次数

标签 统计

c++ ×1

glsl ×1

javascript ×1

npm ×1

opengl ×1

performance ×1

reactjs ×1

shader ×1

shared-libraries ×1