1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【SAPUI5】Uncaught ReferenceError: sap is not definedの解決方法

Last updated at Posted at 2019-02-04

事象

Fioriスタイルのアプリケーションを作り、index.htmlファイルから実行したところ以下のようなエラーになりました。

Uncaught SyntaxError: Unexpected token :
Uncaught ReferenceError: sap is not defined

image.png

ソース

<!DOCTYPE html>
<html>
	<head>
		<!-- bootstrap of SAP UI5 -->
		<script 
			id="sap-ui-bootstrap"
			src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
			data-sap-ui-libs="sap.m, sap.ui.layout, sap.ui.table"
			data-sap-ui-theme="sap_bluecrystal"
			data-sap-ui-xx-bindingSyntax="complex"
			data-sap-ui-resourceroots='{
				"oft.fiori.nov": "./"
			}'>
		</script>
		<script>
			//Component.js日本語
			sap.ui.getCore().attachInit(function(){
				var ComponentContainer = new sap.ui.core.ComponentContainer({
					name: "oft.fiori.nov"
				})
				ComponentContainer.placeAt("content")
			});					
		</script>
	</head>
	<body class="sapUiBody">
		<div id="content"></div>
		
	</body>
</html>

原因

スクリプト内に日本語のコメントがあるため、sap-ui-core.jsファイルの一部が文字化けしていました。このため後続のライブラリが読み込めず、メソッドを実行しようとしたときに"sap is not defined"というエラーが出ていました。

解決方法

日本語のコメントを削除することで解消しました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?