javascript - 将 next.js 更改为 node.js 时,JavaScript 文件在 html 中不起作用
问题描述
我之前写了一个 javascript,并使用 next.js 的指南运行它(npm run dev)并且它工作。现在我想使用 node.js(node app.js) 让它在我的 html 文件中运行,但它似乎不起作用。
在我使用“”的 html 中(index.js 是我以前使用 next.js 时创建的 js)并且我已经将 index.js 放入 assets/js
下面是 index.js
/*jshint esversion: 6 */
import styled from 'styled-components';
const TiltWrap = styled.div`
perspective: 500px;
text-align: center;
display: grid;
justify-content: center;
`;
const TiltStyles = styled.div`
background-image: url('images/drone.jpg');
background-size: contain;
border: 1px solid grey;
width: 300px;
height: 200px;
color: white;
transform:
rotateX(${30}deg)
rotateY(${20}deg)
rotate(${50}deg);
position: relative;
`;
const Index = ({pitch, roll, yaw}) => (
<TiltWrap>
Pitch: {pitch}
Roll: {roll}
Yaw: {yaw}
<TiltStyles pitch={pitch} roll={roll} yaw={yaw} />
</TiltWrap>
);
Index.defaultProps = {
pitch: 0,
roll: 0,
yaw: 0,
};
export default Index;
//for the html, I used below
<script src="assets/js/index.js"></script>
我希望它在我的 html 中运行,但在我添加它之后,我的网站上什么也没发生(在 DreamWeaver 中也不起作用)我应该修改其他文件吗?像 package-lock.jason 吗?应用程序.js?
解决方案
推荐阅读
- vb.net - 屏幕闪烁时的通知 VB.Net
- android - Xamarin.Android 警报管理器 SetSound MP3 文件
- unit-testing - 多个文件上的Sinon错误“尝试包装......已经包装”
- php - Laravel 展示路线中的返回关系
- c - 打开数据库函数需要返回 db 对象,否则它不起作用?
- selenium-webdriver - 有没有人设法让 Botium 与 Cucumber for Java 一起工作?
- javascript - 如何使用反应或javascript检查对象数组中的键值对是否为空?
- javascript - 如何在 smpp 中编码额外的 latin1 字符?
- reactjs - 替换当前网址而不重新加载页面
- php - Symfony 4 - UniqueEntity 约束不显示消息错误